[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6F8HWRKZJMT1JSTREEM3W16":3,"skill-same:01M6F8HWRKZJMT1JSTREEM3W16":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":54,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6F8HWRKZJMT1JSTREEM3W16","clickhouse-core-workflow-a",null,"Design ClickHouse schemas with MergeTree engines, ORDER BY keys, and partitioning.\nUse when creating new tables, choosing engines, designing sort keys,\nor modeling data for analytical workloads.\nTrigger: \"clickhouse schema design\", \"clickhouse table design\",\n\"clickhouse ORDER BY\", \"clickhouse partitioning\", \"MergeTree table\".","ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclickhouse-core-workflow-a\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"workflow","clickhouse core workflow a","clickhouse","core","read","design","trigger","io","modeling","analytical","schema design","edit","write","table","Bash","data","analytics","olap","database","code","2026-11-10 10:12:30",false,"---\nname: clickhouse-core-workflow-a\ndescription: |\n  Design ClickHouse schemas with MergeTree engines, ORDER BY keys, and partitioning.\n  Use when creating new tables, choosing engines, designing sort keys,\n  or modeling data for analytical workloads.\n  Trigger: \"clickhouse schema design\", \"clickhouse table design\",\n  \"clickhouse ORDER BY\", \"clickhouse partitioning\", \"MergeTree table\".\nallowed-tools: Read, Write, Edit, Bash(npm:*), Grep\nversion: 1.0.0\nlicense: MIT\nauthor: Jeremy Longshore \u003Cjeremy@intentsolutions.io>\ntags: [saas, database, analytics, clickhouse, olap]\ncompatible-with: claude-code\n---\n\n# ClickHouse Schema Design (Core Workflow A)\n\n## Overview\n\nDesign ClickHouse tables with correct engine selection, ORDER BY keys,\npartitioning, and codec choices for analytical workloads.\n\n## Prerequisites\n\n- `@clickhouse\u002Fclient` connected (see `clickhouse-install-auth`)\n- Understanding of your query patterns (what you filter and group on)\n\n## Instructions\n\n### Step 1: Choose the Right Engine\n\n| Engine | Best For | Dedup? | Example |\n|--------|----------|--------|---------|\n| `MergeTree` | General analytics, append-only logs | No | Clickstream, IoT |\n| `ReplacingMergeTree` | Mutable rows (upserts) | Yes (on merge) | User profiles, state |\n| `SummingMergeTree` | Pre-aggregated counters | Sums numerics | Page view counts |\n| `AggregatingMergeTree` | Materialized view targets | Merges states | Dashboards |\n| `CollapsingMergeTree` | Stateful row updates | Collapses +-1 | Shopping carts |\n\n**ClickHouse Cloud uses `SharedMergeTree`** — it is a drop-in replacement for\n`MergeTree` on Cloud. You do not need to change your DDL.\n\n### Step 2: Design the ORDER BY (Sort Key)\n\nThe `ORDER BY` clause is the single most important schema decision. It defines:\n- **Primary index** — sparse index over sort-key granules (8192 rows default)\n- **Data layout on disk** — rows sorted physically by these columns\n- **Query speed** — queries filtering on ORDER BY prefix columns hit fewer granules\n\n**Rules of thumb:**\n1. Put low-cardinality filter columns first (`event_type`, `status`)\n2. Then high-cardinality columns you filter on (`user_id`, `tenant_id`)\n3. End with a time column if you use range filters (`created_at`)\n4. Do NOT put high-cardinality columns you never filter on in ORDER BY\n\n```sql\n-- Good: filter by tenant, then by time ranges\nORDER BY (tenant_id, event_type, created_at)\n\n-- Bad: UUID first means every query scans the full index\nORDER BY (event_id, created_at)  -- event_id is random UUID\n```\n\n### Step 3: Schema Examples\n\n#### Event Analytics Table\n\n```sql\nCREATE TABLE analytics.events (\n    event_id     UUID DEFAULT generateUUIDv4(),\n    tenant_id    UInt32,\n    event_type   LowCardinality(String),\n    user_id      UInt64,\n    session_id   String,\n    properties   String CODEC(ZSTD(3)),  -- JSON blob, compress well\n    url          String CODEC(ZSTD(1)),\n    ip_address   IPv4,\n    country      LowCardinality(FixedString(2)),\n    created_at   DateTime64(3) DEFAULT now64(3)\n)\nENGINE = MergeTree()\nORDER BY (tenant_id, event_type, toDate(created_at), user_id)\nPARTITION BY toYYYYMM(created_at)\nTTL created_at + INTERVAL 1 YEAR\nSETTINGS index_granularity = 8192;\n```\n\n#### User Profile Table (Upserts)\n\n```sql\nCREATE TABLE analytics.users (\n    user_id      UInt64,\n    email        String,\n    plan         LowCardinality(String),\n    mrr_cents    UInt32,\n    properties   String CODEC(ZSTD(3)),\n    updated_at   DateTime DEFAULT now()\n)\nENGINE = ReplacingMergeTree(updated_at)   -- keeps latest row per ORDER BY key\nORDER BY user_id;\n\n-- Query with FINAL to get deduplicated results\nSELECT * FROM analytics.users FINAL WHERE user_id = 42;\n```\n\n#### Daily Aggregation Table\n\n```sql\nCREATE TABLE analytics.daily_stats (\n    date         Date,\n    tenant_id    UInt32,\n    event_type   LowCardinality(String),\n    event_count  UInt64,\n    unique_users AggregateFunction(uniq, UInt64)\n)\nENGINE = AggregatingMergeTree()\nORDER BY (tenant_id, event_type, date);\n```\n\n### Step 4: Partitioning Guidelines\n\n| Partition Expression | Typical Use | Parts Per Partition |\n|---------------------|-------------|---------------------|\n| `toYYYYMM(date)` | Most common — monthly | Target 10-1000 |\n| `toMonday(date)` | Weekly rollups | More parts, finer drops |\n| `toYYYYMMDD(date)` | Daily TTL drops | Many parts — use carefully |\n| None | Small tables (\u003C1M rows) | Fine |\n\n**Warning:** Each partition creates separate parts on disk. Over-partitioning\n(e.g., by `user_id`) creates millions of tiny parts and kills performance.\n\n### Step 5: Codecs and Compression\n\n```sql\n-- Column-level compression codecs\ncolumn1  UInt64 CODEC(Delta, ZSTD(3)),      -- Time series \u002F sequential IDs\ncolumn2  Float64 CODEC(Gorilla, ZSTD(1)),   -- Floating point (similar values)\ncolumn3  String CODEC(ZSTD(3)),              -- General text \u002F JSON\ncolumn4  DateTime CODEC(DoubleDelta, ZSTD),  -- Timestamps (near-sequential)\n```\n\n## Applying Schema via Node.js\n\n```typescript\nimport { createClient } from '@clickhouse\u002Fclient';\n\nconst client = createClient({ url: process.env.CLICKHOUSE_HOST! });\n\nasync function applySchema() {\n  await client.command({ query: 'CREATE DATABASE IF NOT EXISTS analytics' });\n\n  await client.command({\n    query: `\n      CREATE TABLE IF NOT EXISTS analytics.events (\n        event_id   UUID DEFAULT generateUUIDv4(),\n        tenant_id  UInt32,\n        event_type LowCardinality(String),\n        user_id    UInt64,\n        payload    String CODEC(ZSTD(3)),\n        created_at DateTime DEFAULT now()\n      )\n      ENGINE = MergeTree()\n      ORDER BY (tenant_id, event_type, created_at)\n      PARTITION BY toYYYYMM(created_at)\n    `,\n  });\n\n  console.log('Schema applied.');\n}\n```\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `ORDER BY expression not in primary key` | PRIMARY KEY != ORDER BY | Remove explicit PRIMARY KEY or align |\n| `Too many parts (300+)` | Over-partitioning | Use coarser partition expression |\n| `Cannot convert String to UInt64` | Wrong data type | Match insert types to schema |\n| `TTL expression type mismatch` | TTL on non-date column | TTL must reference DateTime column |\n\n## Resources\n\n- [MergeTree Engine](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fengines\u002Ftable-engines\u002Fmergetree-family\u002Fmergetree)\n- [ReplacingMergeTree](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fengines\u002Ftable-engines\u002Fmergetree-family\u002Freplacingmergetree)\n- [Codecs & Compression](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fsql-reference\u002Fstatements\u002Fcreate\u002Ftable#column_compression_codec)\n\n## Next Steps\n\nFor inserting and querying data, see `clickhouse-core-workflow-b`.\n\n","# ClickHouse Schema Design (Core Workflow A)\n\n## Overview\n\nDesign ClickHouse tables with correct engine selection, ORDER BY keys,\npartitioning, and codec choices for analytical workloads.\n\n## Prerequisites\n\n- `@clickhouse\u002Fclient` connected (see `clickhouse-install-auth`)\n- Understanding of your query patterns (what you filter and group on)\n\n## Instructions\n\n### Step 1: Choose the Right Engine\n\n| Engine | Best For | Dedup? | Example |\n|--------|----------|--------|---------|\n| `MergeTree` | General analytics, append-only logs | No | Clickstream, IoT |\n| `ReplacingMergeTree` | Mutable rows (upserts) | Yes (on merge) | User profiles, state |\n| `SummingMergeTree` | Pre-aggregated counters | Sums numerics | Page view counts |\n| `AggregatingMergeTree` | Materialized view targets | Merges states | Dashboards |\n| `CollapsingMergeTree` | Stateful row updates | Collapses +-1 | Shopping carts |\n\n**ClickHouse Cloud uses `SharedMergeTree`** — it is a drop-in replacement for\n`MergeTree` on Cloud. You do not need to change your DDL.\n\n### Step 2: Design the ORDER BY (Sort Key)\n\nThe `ORDER BY` clause is the single most important schema decision. It defines:\n- **Primary index** — sparse index over sort-key granules (8192 rows default)\n- **Data layout on disk** — rows sorted physically by these columns\n- **Query speed** — queries filtering on ORDER BY prefix columns hit fewer granules\n\n**Rules of thumb:**\n1. Put low-cardinality filter columns first (`event_type`, `status`)\n2. Then high-cardinality columns you filter on (`user_id`, `tenant_id`)\n3. End with a time column if you use range filters (`created_at`)\n4. Do NOT put high-cardinality columns you never filter on in ORDER BY\n\n```sql\n-- Good: filter by tenant, then by time ranges\nORDER BY (tenant_id, event_type, created_at)\n\n-- Bad: UUID first means every query scans the full index\nORDER BY (event_id, created_at)  -- event_id is random UUID\n```\n\n### Step 3: Schema Examples\n\n#### Event Analytics Table\n\n```sql\nCREATE TABLE analytics.events (\n    event_id     UUID DEFAULT generateUUIDv4(),\n    tenant_id    UInt32,\n    event_type   LowCardinality(String),\n    user_id      UInt64,\n    session_id   String,\n    properties   String CODEC(ZSTD(3)),  -- JSON blob, compress well\n    url          String CODEC(ZSTD(1)),\n    ip_address   IPv4,\n    country      LowCardinality(FixedString(2)),\n    created_at   DateTime64(3) DEFAULT now64(3)\n)\nENGINE = MergeTree()\nORDER BY (tenant_id, event_type, toDate(created_at), user_id)\nPARTITION BY toYYYYMM(created_at)\nTTL created_at + INTERVAL 1 YEAR\nSETTINGS index_granularity = 8192;\n```\n\n#### User Profile Table (Upserts)\n\n```sql\nCREATE TABLE analytics.users (\n    user_id      UInt64,\n    email        String,\n    plan         LowCardinality(String),\n    mrr_cents    UInt32,\n    properties   String CODEC(ZSTD(3)),\n    updated_at   DateTime DEFAULT now()\n)\nENGINE = ReplacingMergeTree(updated_at)   -- keeps latest row per ORDER BY key\nORDER BY user_id;\n\n-- Query with FINAL to get deduplicated results\nSELECT * FROM analytics.users FINAL WHERE user_id = 42;\n```\n\n#### Daily Aggregation Table\n\n```sql\nCREATE TABLE analytics.daily_stats (\n    date         Date,\n    tenant_id    UInt32,\n    event_type   LowCardinality(String),\n    event_count  UInt64,\n    unique_users AggregateFunction(uniq, UInt64)\n)\nENGINE = AggregatingMergeTree()\nORDER BY (tenant_id, event_type, date);\n```\n\n### Step 4: Partitioning Guidelines\n\n| Partition Expression | Typical Use | Parts Per Partition |\n|---------------------|-------------|---------------------|\n| `toYYYYMM(date)` | Most common — monthly | Target 10-1000 |\n| `toMonday(date)` | Weekly rollups | More parts, finer drops |\n| `toYYYYMMDD(date)` | Daily TTL drops | Many parts — use carefully |\n| None | Small tables (\u003C1M rows) | Fine |\n\n**Warning:** Each partition creates separate parts on disk. Over-partitioning\n(e.g., by `user_id`) creates millions of tiny parts and kills performance.\n\n### Step 5: Codecs and Compression\n\n```sql\n-- Column-level compression codecs\ncolumn1  UInt64 CODEC(Delta, ZSTD(3)),      -- Time series \u002F sequential IDs\ncolumn2  Float64 CODEC(Gorilla, ZSTD(1)),   -- Floating point (similar values)\ncolumn3  String CODEC(ZSTD(3)),              -- General text \u002F JSON\ncolumn4  DateTime CODEC(DoubleDelta, ZSTD),  -- Timestamps (near-sequential)\n```\n\n## Applying Schema via Node.js\n\n```typescript\nimport { createClient } from '@clickhouse\u002Fclient';\n\nconst client = createClient({ url: process.env.CLICKHOUSE_HOST! });\n\nasync function applySchema() {\n  await client.command({ query: 'CREATE DATABASE IF NOT EXISTS analytics' });\n\n  await client.command({\n    query: `\n      CREATE TABLE IF NOT EXISTS analytics.events (\n        event_id   UUID DEFAULT generateUUIDv4(),\n        tenant_id  UInt32,\n        event_type LowCardinality(String),\n        user_id    UInt64,\n        payload    String CODEC(ZSTD(3)),\n        created_at DateTime DEFAULT now()\n      )\n      ENGINE = MergeTree()\n      ORDER BY (tenant_id, event_type, created_at)\n      PARTITION BY toYYYYMM(created_at)\n    `,\n  });\n\n  console.log('Schema applied.');\n}\n```\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `ORDER BY expression not in primary key` | PRIMARY KEY != ORDER BY | Remove explicit PRIMARY KEY or align |\n| `Too many parts (300+)` | Over-partitioning | Use coarser partition expression |\n| `Cannot convert String to UInt64` | Wrong data type | Match insert types to schema |\n| `TTL expression type mismatch` | TTL on non-date column | TTL must reference DateTime column |\n\n## Resources\n\n- [MergeTree Engine](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fengines\u002Ftable-engines\u002Fmergetree-family\u002Fmergetree)\n- [ReplacingMergeTree](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fengines\u002Ftable-engines\u002Fmergetree-family\u002Freplacingmergetree)\n- [Codecs & Compression](https:\u002F\u002Fclickhouse.com\u002Fdocs\u002Fsql-reference\u002Fstatements\u002Fcreate\u002Ftable#column_compression_codec)\n\n## Next Steps\n\nFor inserting and querying data, see `clickhouse-core-workflow-b`.\n\n",{"name":5,"tags":44,"author":46,"license":15,"version":47,"description":48,"allowed-tools":49,"compatible-with":50},[45,37,35,21,36],"saas","Jeremy Longshore \u003Cjeremy@intentsolutions.io>","1.0.0","Design ClickHouse schemas with MergeTree engines, ORDER BY keys, and partitioning.\nUse when creating new tables, choosing engines, designing sort keys,\nor modeling data for analytical workloads.\nTrigger: \"clickhouse schema design\", \"clickhouse table design\",\n\"clickhouse ORDER BY\", \"clickhouse partitioning\", \"MergeTree table\".\n","Read, Write, Edit, Bash(npm:*), Grep","claude-code","main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclickhouse-core-workflow-a",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill clickhouse-core-workflow-a",{"tool":66,"command":67},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill clickhouse-core-workflow-a",{"tool":69,"command":70},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill clickhouse-core-workflow-a","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fjeremylongshore\u002Fclaude-code-plugins-plus-skills\u002Fclickhouse-core-workflow-a\u002FSKILL.md",true,[],[75,84,93,102,108,114],{"skillNo":76,"name":77,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":39},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[81,82,83],"model","model hierarchy","model hierarchy skill",{"skillNo":85,"name":86,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":39},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[90,91,92],"MCP","zoom","zoom mcp",{"skillNo":94,"name":95,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":39},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[99,100,101,91],"sdk","zoom apps sdk","apps",{"skillNo":103,"name":104,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":39},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[104],{"skillNo":109,"name":110,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":39},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[110],{"skillNo":115,"name":116,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":39},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[116]]