clickhouse-js

Applies ClickHouse schema design, query, and Node.js client conventions to database code.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill clickhouse-js-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clickhouse-js
Source: https://github.com/avbel/ai-skills/tree/main/skills/clickhouse-js
Command: npx skills add https://github.com/avbel/ai-skills --skill clickhouse-js-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @clickhouse/client.

What problem does it solve? Writing efficient ClickHouse schemas and queries requires deep knowledge of MergeTree engines, ORDER BY design, and aggregate combinators that developers often get wrong, leading to slow queries and incorrect deduplication. ## Core Features & Use Cases - Schema & Engine Guidance: Covers MergeTree engine selection, ORDER BY/primary key design, data types, codecs, partitioning, and materialized views. - Query & Aggregation Patterns: Documents ClickHouse-specific SELECT features (FINAL, PREWHERE, ARRAY JOIN, LIMIT BY), aggregate combinators like -If and -State, and window functions. - Node.js Client Conventions: Provides @clickhouse/client patterns for parameterized queries, batched inserts, compression, type mapping, and connection lifecycle. - Use Case: When building an analytics table for event data, use this Skill to choose ReplacingMergeTree with the correct ORDER BY, write a batched insert via the Node.js client, and query with argMax for latest-state retrieval. ## Quick Start Use the clickhouse-js skill to design a MergeTree table and write a parameterized Node.js query for my events data.

Frequently Asked Questions about clickhouse-js

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a ClickHouse ORDER BY key for fast queries?▼

Put columns used in WHERE clauses first, ordered by ascending cardinality (low-cardinality first). ClickHouse uses a sparse index with one entry per granule, so filtering on columns not in ORDER BY causes full granule scans.

How to insert data into ClickHouse from Node.js?▼

Use @clickhouse/client's insert method with an array of objects and format JSONEachRow. Batch 10K-100K+ rows per insert, or enable async_insert in clickhouse_settings for high-frequency small inserts.

Does ReplacingMergeTree automatically deduplicate rows?▼

No, deduplication happens only during background merges, which are eventual. Use SELECT with FINAL or GROUP BY in queries to guarantee correct deduplicated results before merges complete.

Why are my ClickHouse queries slow on large tables?▼

Common causes include filtering on columns not in the ORDER BY key, over-partitioning beyond 1000 partitions, and using Nullable columns unnecessarily. Add skip indexes like bloom_filter for frequently filtered non-key columns.

Can I use @clickhouse/client in the browser or edge runtimes?▼

Yes, use @clickhouse/client-web which offers the same API for browser and edge environments. It does not support streaming inserts and rejects zstd compression, unlike the Node.js client.