[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AK3BVMGM6VFEV5GPS0M6W3":3,"skill-same:01M7AK3BVMGM6VFEV5GPS0M6W3":47},{"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":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7AK3BVMGM6VFEV5GPS0M6W3","clickhouse-io",null,"ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.","Cyrilthetecchieee\u002Fcyril-code-","Cyrilthetecchieee","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F219787998?v=4","01M7AF0MMMKRAA0H61XMJPV92H","Julian Cyril D ","01M7AF0MQ10AVG6QJQ1C2BC0F5",2,"MIT","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fja-JP\u002Fskills\u002Fclickhouse-io\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: clickhouse-io\ndescription: ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.\n---\n\n# ClickHouse 分析パターン\n\n高性能分析とデータエンジニアリングのためのClickHouse固有のパターン。\n\n## 概要\n\nClickHouseは、オンライン分析処理（OLAP）用のカラム指向データベース管理システム（DBMS）です。大規模データセットに対する高速分析クエリに最適化されています。\n\n**主な機能:**\n- カラム指向ストレージ\n- データ圧縮\n- 並列クエリ実行\n- 分散クエリ\n- リアルタイム分析\n\n## テーブル設計パターン\n\n### MergeTreeエンジン（最も一般的）\n\n```sql\nCREATE TABLE markets_analytics (\n    date Date,\n    market_id String,\n    market_name String,\n    volume UInt64,\n    trades UInt32,\n    unique_traders UInt32,\n    avg_trade_size Float64,\n    created_at DateTime\n) ENGINE = MergeTree()\nPARTITION BY toYYYYMM(date)\nORDER BY (date, market_id)\nSETTINGS index_granularity = 8192;\n```\n\n### ReplacingMergeTree（重複排除）\n\n```sql\n-- 重複がある可能性のあるデータ（複数のソースからなど）用\nCREATE TABLE user_events (\n    event_id String,\n    user_id String,\n    event_type String,\n    timestamp DateTime,\n    properties String\n) ENGINE = ReplacingMergeTree()\nPARTITION BY toYYYYMM(timestamp)\nORDER BY (user_id, event_id, timestamp)\nPRIMARY KEY (user_id, event_id);\n```\n\n### AggregatingMergeTree（事前集計）\n\n```sql\n-- 集計メトリクスの維持用\nCREATE TABLE market_stats_hourly (\n    hour DateTime,\n    market_id String,\n    total_volume AggregateFunction(sum, UInt64),\n    total_trades AggregateFunction(count, UInt32),\n    unique_users AggregateFunction(uniq, String)\n) ENGINE = AggregatingMergeTree()\nPARTITION BY toYYYYMM(hour)\nORDER BY (hour, market_id);\n\n-- 集計データのクエリ\nSELECT\n    hour,\n    market_id,\n    sumMerge(total_volume) AS volume,\n    countMerge(total_trades) AS trades,\n    uniqMerge(unique_users) AS users\nFROM market_stats_hourly\nWHERE hour >= toStartOfHour(now() - INTERVAL 24 HOUR)\nGROUP BY hour, market_id\nORDER BY hour DESC;\n```\n\n## クエリ最適化パターン\n\n### 効率的なフィルタリング\n\n```sql\n-- PASS: 良い: インデックス列を最初に使用\nSELECT *\nFROM markets_analytics\nWHERE date >= '2025-01-01'\n  AND market_id = 'market-123'\n  AND volume > 1000\nORDER BY date DESC\nLIMIT 100;\n\n-- FAIL: 悪い: インデックスのない列を最初にフィルタリング\nSELECT *\nFROM markets_analytics\nWHERE volume > 1000\n  AND market_name LIKE '%election%'\n  AND date >= '2025-01-01';\n```\n\n### 集計\n\n```sql\n-- PASS: 良い: ClickHouse固有の集計関数を使用\nSELECT\n    toStartOfDay(created_at) AS day,\n    market_id,\n    sum(volume) AS total_volume,\n    count() AS total_trades,\n    uniq(trader_id) AS unique_traders,\n    avg(trade_size) AS avg_size\nFROM trades\nWHERE created_at >= today() - INTERVAL 7 DAY\nGROUP BY day, market_id\nORDER BY day DESC, total_volume DESC;\n\n-- PASS: パーセンタイルにはquantileを使用（percentileより効率的）\nSELECT\n    quantile(0.50)(trade_size) AS median,\n    quantile(0.95)(trade_size) AS p95,\n    quantile(0.99)(trade_size) AS p99\nFROM trades\nWHERE created_at >= now() - INTERVAL 1 HOUR;\n```\n\n### ウィンドウ関数\n\n```sql\n-- 累計計算\nSELECT\n    date,\n    market_id,\n    volume,\n    sum(volume) OVER (\n        PARTITION BY market_id\n        ORDER BY date\n        ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n    ) AS cumulative_volume\nFROM markets_analytics\nWHERE date >= today() - INTERVAL 30 DAY\nORDER BY market_id, date;\n```\n\n## データ挿入パターン\n\n### 一括挿入（推奨）\n\n```typescript\nimport { createClient } from '@clickhouse\u002Fclient'\n\nconst clickhouse = createClient({\n  url: process.env.CLICKHOUSE_URL ?? 'http:\u002F\u002Flocalhost:8123',\n  username: process.env.CLICKHOUSE_USER,\n  password: process.env.CLICKHOUSE_PASSWORD\n})\n\n\u002F\u002F PASS: バッチ挿入（効率的）\nasync function bulkInsertTrades(trades: Trade[]) {\n  await clickhouse.insert({\n    table: 'trades',\n    values: trades.map(trade => ({\n      id: trade.id,\n      market_id: trade.market_id,\n      user_id: trade.user_id,\n      amount: trade.amount,\n      timestamp: trade.timestamp.toISOString()\n    })),\n    format: 'JSONEachRow'\n  })\n}\n\n\u002F\u002F FAIL: 個別挿入（低速）\nasync function insertTrade(trade: Trade) {\n  \u002F\u002F ループ内でこれをしないでください！\n  await clickhouse.insert({\n    table: 'trades',\n    values: [{\n      id: trade.id,\n      market_id: trade.market_id,\n      user_id: trade.user_id,\n      amount: trade.amount,\n      timestamp: trade.timestamp.toISOString()\n    }],\n    format: 'JSONEachRow'\n  })\n}\n```\n\n### ストリーミング挿入\n\n```typescript\n\u002F\u002F 継続的なデータ取り込み用\nimport { Readable } from 'node:stream'\n\nasync function streamInserts(dataSource: AsyncIterable\u003CRecord\u003Cstring, unknown>>) {\n  await clickhouse.insert({\n    table: 'trades',\n    values: Readable.from(dataSource, { objectMode: true }),\n    format: 'JSONEachRow'\n  })\n}\n```\n\n## マテリアライズドビュー\n\n### リアルタイム集計\n\n```sql\n-- 時間別統計のマテリアライズドビューを作成\nCREATE MATERIALIZED VIEW market_stats_hourly_mv\nTO market_stats_hourly\nAS SELECT\n    toStartOfHour(timestamp) AS hour,\n    market_id,\n    sumState(amount) AS total_volume,\n    countState() AS total_trades,\n    uniqState(user_id) AS unique_users\nFROM trades\nGROUP BY hour, market_id;\n\n-- マテリアライズドビューのクエリ\nSELECT\n    hour,\n    market_id,\n    sumMerge(total_volume) AS volume,\n    countMerge(total_trades) AS trades,\n    uniqMerge(unique_users) AS users\nFROM market_stats_hourly\nWHERE hour >= now() - INTERVAL 24 HOUR\nGROUP BY hour, market_id;\n```\n\n## パフォーマンスモニタリング\n\n### クエリパフォーマンス\n\n```sql\n-- 低速クエリをチェック\nSELECT\n    query_id,\n    user,\n    query,\n    query_duration_ms,\n    read_rows,\n    read_bytes,\n    memory_usage\nFROM system.query_log\nWHERE type = 'QueryFinish'\n  AND query_duration_ms > 1000\n  AND event_time >= now() - INTERVAL 1 HOUR\nORDER BY query_duration_ms DESC\nLIMIT 10;\n```\n\n### テーブル統計\n\n```sql\n-- テーブルサイズをチェック\nSELECT\n    database,\n    table,\n    formatReadableSize(sum(bytes)) AS size,\n    sum(rows) AS rows,\n    max(modification_time) AS latest_modification\nFROM system.parts\nWHERE active\nGROUP BY database, table\nORDER BY sum(bytes) DESC;\n```\n\n## 一般的な分析クエリ\n\n### 時系列分析\n\n```sql\n-- 日次アクティブユーザー\nSELECT\n    toDate(timestamp) AS date,\n    uniq(user_id) AS daily_active_users\nFROM events\nWHERE timestamp >= today() - INTERVAL 30 DAY\nGROUP BY date\nORDER BY date;\n\n-- リテンション分析\nSELECT\n    signup_date,\n    countIf(days_since_signup = 0) AS day_0,\n    countIf(days_since_signup = 1) AS day_1,\n    countIf(days_since_signup = 7) AS day_7,\n    countIf(days_since_signup = 30) AS day_30\nFROM (\n    SELECT\n        user_id,\n        min(toDate(timestamp)) AS signup_date,\n        toDate(timestamp) AS activity_date,\n        dateDiff('day', signup_date, activity_date) AS days_since_signup\n    FROM events\n    GROUP BY user_id, activity_date\n)\nGROUP BY signup_date\nORDER BY signup_date DESC;\n```\n\n### ファネル分析\n\n```sql\n-- コンバージョンファネル\nSELECT\n    countIf(step = 'viewed_market') AS viewed,\n    countIf(step = 'clicked_trade') AS clicked,\n    countIf(step = 'completed_trade') AS completed,\n    round(clicked \u002F viewed * 100, 2) AS view_to_click_rate,\n    round(completed \u002F clicked * 100, 2) AS click_to_completion_rate\nFROM (\n    SELECT\n        user_id,\n        session_id,\n        event_type AS step\n    FROM events\n    WHERE event_date = today()\n)\nGROUP BY session_id;\n```\n\n### コホート分析\n\n```sql\n-- サインアップ月別のユーザーコホート\nSELECT\n    toStartOfMonth(signup_date) AS cohort,\n    toStartOfMonth(activity_date) AS month,\n    dateDiff('month', cohort, month) AS months_since_signup,\n    count(DISTINCT user_id) AS active_users\nFROM (\n    SELECT\n        user_id,\n        min(toDate(timestamp)) OVER (PARTITION BY user_id) AS signup_date,\n        toDate(timestamp) AS activity_date\n    FROM events\n)\nGROUP BY cohort, month, months_since_signup\nORDER BY cohort, months_since_signup;\n```\n\n## データパイプラインパターン\n\n### ETLパターン\n\n```typescript\n\u002F\u002F 抽出、変換、ロード\nasync function etlPipeline() {\n  \u002F\u002F 1. ソースから抽出\n  const rawData = await extractFromPostgres()\n\n  \u002F\u002F 2. 変換\n  const transformed = rawData.map(row => ({\n    date: new Date(row.created_at).toISOString().split('T')[0],\n    market_id: row.market_slug,\n    volume: parseFloat(row.total_volume),\n    trades: parseInt(row.trade_count)\n  }))\n\n  \u002F\u002F 3. ClickHouseにロード\n  await bulkInsertToClickHouse(transformed)\n}\n\n\u002F\u002F 定期的に実行\nsetInterval(etlPipeline, 60 * 60 * 1000)  \u002F\u002F 1時間ごと\n```\n\n### 変更データキャプチャ（CDC）\n\n```typescript\n\u002F\u002F PostgreSQLの変更をリッスンしてClickHouseに同期\nimport { Client } from 'pg'\n\nconst pgClient = new Client({ connectionString: process.env.DATABASE_URL })\n\npgClient.query('LISTEN market_updates')\n\npgClient.on('notification', async (msg) => {\n  const update = JSON.parse(msg.payload)\n\n  await clickhouse.insert({\n    table: 'market_updates',\n    values: [\n      {\n        market_id: update.id,\n        event_type: update.operation,  \u002F\u002F INSERT, UPDATE, DELETE\n        timestamp: new Date(),\n        data: JSON.stringify(update.new_data)\n      }\n    ],\n    format: 'JSONEachRow'\n  })\n})\n```\n\n## ベストプラクティス\n\n### 1. パーティショニング戦略\n- 時間でパーティション化（通常は月または日）\n- パーティションが多すぎないようにする（パフォーマンスへの影響）\n- パーティションキーにはDATEタイプを使用\n\n### 2. ソートキー\n- 最も頻繁にフィルタリングされる列を最初に配置\n- カーディナリティを考慮（高カーディナリティを最初に）\n- 順序は圧縮に影響\n\n### 3. データタイプ\n- 最小の適切なタイプを使用（UInt32 vs UInt64）\n- 繰り返される文字列にはLowCardinalityを使用\n- カテゴリカルデータにはEnumを使用\n\n### 4. 避けるべき\n- SELECT *（列を指定）\n- FINAL（代わりにクエリ前にデータをマージ）\n- JOINが多すぎる（分析用に非正規化）\n- 小さな頻繁な挿入（代わりにバッチ処理）\n\n### 5. モニタリング\n- クエリパフォーマンスを追跡\n- ディスク使用量を監視\n- マージ操作をチェック\n- 低速クエリログをレビュー\n\n**注意**: ClickHouseは分析ワークロードに優れています。クエリパターンに合わせてテーブルを設計し、挿入をバッチ化し、リアルタイム集計にはマテリアライズドビューを活用します。\n","# ClickHouse 分析パターン\n\n高性能分析とデータエンジニアリングのためのClickHouse固有のパターン。\n\n## 概要\n\nClickHouseは、オンライン分析処理（OLAP）用のカラム指向データベース管理システム（DBMS）です。大規模データセットに対する高速分析クエリに最適化されています。\n\n**主な機能:**\n- カラム指向ストレージ\n- データ圧縮\n- 並列クエリ実行\n- 分散クエリ\n- リアルタイム分析\n\n## テーブル設計パターン\n\n### MergeTreeエンジン（最も一般的）\n\n```sql\nCREATE TABLE markets_analytics (\n    date Date,\n    market_id String,\n    market_name String,\n    volume UInt64,\n    trades UInt32,\n    unique_traders UInt32,\n    avg_trade_size Float64,\n    created_at DateTime\n) ENGINE = MergeTree()\nPARTITION BY toYYYYMM(date)\nORDER BY (date, market_id)\nSETTINGS index_granularity = 8192;\n```\n\n### ReplacingMergeTree（重複排除）\n\n```sql\n-- 重複がある可能性のあるデータ（複数のソースからなど）用\nCREATE TABLE user_events (\n    event_id String,\n    user_id String,\n    event_type String,\n    timestamp DateTime,\n    properties String\n) ENGINE = ReplacingMergeTree()\nPARTITION BY toYYYYMM(timestamp)\nORDER BY (user_id, event_id, timestamp)\nPRIMARY KEY (user_id, event_id);\n```\n\n### AggregatingMergeTree（事前集計）\n\n```sql\n-- 集計メトリクスの維持用\nCREATE TABLE market_stats_hourly (\n    hour DateTime,\n    market_id String,\n    total_volume AggregateFunction(sum, UInt64),\n    total_trades AggregateFunction(count, UInt32),\n    unique_users AggregateFunction(uniq, String)\n) ENGINE = AggregatingMergeTree()\nPARTITION BY toYYYYMM(hour)\nORDER BY (hour, market_id);\n\n-- 集計データのクエリ\nSELECT\n    hour,\n    market_id,\n    sumMerge(total_volume) AS volume,\n    countMerge(total_trades) AS trades,\n    uniqMerge(unique_users) AS users\nFROM market_stats_hourly\nWHERE hour >= toStartOfHour(now() - INTERVAL 24 HOUR)\nGROUP BY hour, market_id\nORDER BY hour DESC;\n```\n\n## クエリ最適化パターン\n\n### 効率的なフィルタリング\n\n```sql\n-- PASS: 良い: インデックス列を最初に使用\nSELECT *\nFROM markets_analytics\nWHERE date >= '2025-01-01'\n  AND market_id = 'market-123'\n  AND volume > 1000\nORDER BY date DESC\nLIMIT 100;\n\n-- FAIL: 悪い: インデックスのない列を最初にフィルタリング\nSELECT *\nFROM markets_analytics\nWHERE volume > 1000\n  AND market_name LIKE '%election%'\n  AND date >= '2025-01-01';\n```\n\n### 集計\n\n```sql\n-- PASS: 良い: ClickHouse固有の集計関数を使用\nSELECT\n    toStartOfDay(created_at) AS day,\n    market_id,\n    sum(volume) AS total_volume,\n    count() AS total_trades,\n    uniq(trader_id) AS unique_traders,\n    avg(trade_size) AS avg_size\nFROM trades\nWHERE created_at >= today() - INTERVAL 7 DAY\nGROUP BY day, market_id\nORDER BY day DESC, total_volume DESC;\n\n-- PASS: パーセンタイルにはquantileを使用（percentileより効率的）\nSELECT\n    quantile(0.50)(trade_size) AS median,\n    quantile(0.95)(trade_size) AS p95,\n    quantile(0.99)(trade_size) AS p99\nFROM trades\nWHERE created_at >= now() - INTERVAL 1 HOUR;\n```\n\n### ウィンドウ関数\n\n```sql\n-- 累計計算\nSELECT\n    date,\n    market_id,\n    volume,\n    sum(volume) OVER (\n        PARTITION BY market_id\n        ORDER BY date\n        ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n    ) AS cumulative_volume\nFROM markets_analytics\nWHERE date >= today() - INTERVAL 30 DAY\nORDER BY market_id, date;\n```\n\n## データ挿入パターン\n\n### 一括挿入（推奨）\n\n```typescript\nimport { createClient } from '@clickhouse\u002Fclient'\n\nconst clickhouse = createClient({\n  url: process.env.CLICKHOUSE_URL ?? 'http:\u002F\u002Flocalhost:8123',\n  username: process.env.CLICKHOUSE_USER,\n  password: process.env.CLICKHOUSE_PASSWORD\n})\n\n\u002F\u002F PASS: バッチ挿入（効率的）\nasync function bulkInsertTrades(trades: Trade[]) {\n  await clickhouse.insert({\n    table: 'trades',\n    values: trades.map(trade => ({\n      id: trade.id,\n      market_id: trade.market_id,\n      user_id: trade.user_id,\n      amount: trade.amount,\n      timestamp: trade.timestamp.toISOString()\n    })),\n    format: 'JSONEachRow'\n  })\n}\n\n\u002F\u002F FAIL: 個別挿入（低速）\nasync function insertTrade(trade: Trade) {\n  \u002F\u002F ループ内でこれをしないでください！\n  await clickhouse.insert({\n    table: 'trades',\n    values: [{\n      id: trade.id,\n      market_id: trade.market_id,\n      user_id: trade.user_id,\n      amount: trade.amount,\n      timestamp: trade.timestamp.toISOString()\n    }],\n    format: 'JSONEachRow'\n  })\n}\n```\n\n### ストリーミング挿入\n\n```typescript\n\u002F\u002F 継続的なデータ取り込み用\nimport { Readable } from 'node:stream'\n\nasync function streamInserts(dataSource: AsyncIterable\u003CRecord\u003Cstring, unknown>>) {\n  await clickhouse.insert({\n    table: 'trades',\n    values: Readable.from(dataSource, { objectMode: true }),\n    format: 'JSONEachRow'\n  })\n}\n```\n\n## マテリアライズドビュー\n\n### リアルタイム集計\n\n```sql\n-- 時間別統計のマテリアライズドビューを作成\nCREATE MATERIALIZED VIEW market_stats_hourly_mv\nTO market_stats_hourly\nAS SELECT\n    toStartOfHour(timestamp) AS hour,\n    market_id,\n    sumState(amount) AS total_volume,\n    countState() AS total_trades,\n    uniqState(user_id) AS unique_users\nFROM trades\nGROUP BY hour, market_id;\n\n-- マテリアライズドビューのクエリ\nSELECT\n    hour,\n    market_id,\n    sumMerge(total_volume) AS volume,\n    countMerge(total_trades) AS trades,\n    uniqMerge(unique_users) AS users\nFROM market_stats_hourly\nWHERE hour >= now() - INTERVAL 24 HOUR\nGROUP BY hour, market_id;\n```\n\n## パフォーマンスモニタリング\n\n### クエリパフォーマンス\n\n```sql\n-- 低速クエリをチェック\nSELECT\n    query_id,\n    user,\n    query,\n    query_duration_ms,\n    read_rows,\n    read_bytes,\n    memory_usage\nFROM system.query_log\nWHERE type = 'QueryFinish'\n  AND query_duration_ms > 1000\n  AND event_time >= now() - INTERVAL 1 HOUR\nORDER BY query_duration_ms DESC\nLIMIT 10;\n```\n\n### テーブル統計\n\n```sql\n-- テーブルサイズをチェック\nSELECT\n    database,\n    table,\n    formatReadableSize(sum(bytes)) AS size,\n    sum(rows) AS rows,\n    max(modification_time) AS latest_modification\nFROM system.parts\nWHERE active\nGROUP BY database, table\nORDER BY sum(bytes) DESC;\n```\n\n## 一般的な分析クエリ\n\n### 時系列分析\n\n```sql\n-- 日次アクティブユーザー\nSELECT\n    toDate(timestamp) AS date,\n    uniq(user_id) AS daily_active_users\nFROM events\nWHERE timestamp >= today() - INTERVAL 30 DAY\nGROUP BY date\nORDER BY date;\n\n-- リテンション分析\nSELECT\n    signup_date,\n    countIf(days_since_signup = 0) AS day_0,\n    countIf(days_since_signup = 1) AS day_1,\n    countIf(days_since_signup = 7) AS day_7,\n    countIf(days_since_signup = 30) AS day_30\nFROM (\n    SELECT\n        user_id,\n        min(toDate(timestamp)) AS signup_date,\n        toDate(timestamp) AS activity_date,\n        dateDiff('day', signup_date, activity_date) AS days_since_signup\n    FROM events\n    GROUP BY user_id, activity_date\n)\nGROUP BY signup_date\nORDER BY signup_date DESC;\n```\n\n### ファネル分析\n\n```sql\n-- コンバージョンファネル\nSELECT\n    countIf(step = 'viewed_market') AS viewed,\n    countIf(step = 'clicked_trade') AS clicked,\n    countIf(step = 'completed_trade') AS completed,\n    round(clicked \u002F viewed * 100, 2) AS view_to_click_rate,\n    round(completed \u002F clicked * 100, 2) AS click_to_completion_rate\nFROM (\n    SELECT\n        user_id,\n        session_id,\n        event_type AS step\n    FROM events\n    WHERE event_date = today()\n)\nGROUP BY session_id;\n```\n\n### コホート分析\n\n```sql\n-- サインアップ月別のユーザーコホート\nSELECT\n    toStartOfMonth(signup_date) AS cohort,\n    toStartOfMonth(activity_date) AS month,\n    dateDiff('month', cohort, month) AS months_since_signup,\n    count(DISTINCT user_id) AS active_users\nFROM (\n    SELECT\n        user_id,\n        min(toDate(timestamp)) OVER (PARTITION BY user_id) AS signup_date,\n        toDate(timestamp) AS activity_date\n    FROM events\n)\nGROUP BY cohort, month, months_since_signup\nORDER BY cohort, months_since_signup;\n```\n\n## データパイプラインパターン\n\n### ETLパターン\n\n```typescript\n\u002F\u002F 抽出、変換、ロード\nasync function etlPipeline() {\n  \u002F\u002F 1. ソースから抽出\n  const rawData = await extractFromPostgres()\n\n  \u002F\u002F 2. 変換\n  const transformed = rawData.map(row => ({\n    date: new Date(row.created_at).toISOString().split('T')[0],\n    market_id: row.market_slug,\n    volume: parseFloat(row.total_volume),\n    trades: parseInt(row.trade_count)\n  }))\n\n  \u002F\u002F 3. ClickHouseにロード\n  await bulkInsertToClickHouse(transformed)\n}\n\n\u002F\u002F 定期的に実行\nsetInterval(etlPipeline, 60 * 60 * 1000)  \u002F\u002F 1時間ごと\n```\n\n### 変更データキャプチャ（CDC）\n\n```typescript\n\u002F\u002F PostgreSQLの変更をリッスンしてClickHouseに同期\nimport { Client } from 'pg'\n\nconst pgClient = new Client({ connectionString: process.env.DATABASE_URL })\n\npgClient.query('LISTEN market_updates')\n\npgClient.on('notification', async (msg) => {\n  const update = JSON.parse(msg.payload)\n\n  await clickhouse.insert({\n    table: 'market_updates',\n    values: [\n      {\n        market_id: update.id,\n        event_type: update.operation,  \u002F\u002F INSERT, UPDATE, DELETE\n        timestamp: new Date(),\n        data: JSON.stringify(update.new_data)\n      }\n    ],\n    format: 'JSONEachRow'\n  })\n})\n```\n\n## ベストプラクティス\n\n### 1. パーティショニング戦略\n- 時間でパーティション化（通常は月または日）\n- パーティションが多すぎないようにする（パフォーマンスへの影響）\n- パーティションキーにはDATEタイプを使用\n\n### 2. ソートキー\n- 最も頻繁にフィルタリングされる列を最初に配置\n- カーディナリティを考慮（高カーディナリティを最初に）\n- 順序は圧縮に影響\n\n### 3. データタイプ\n- 最小の適切なタイプを使用（UInt32 vs UInt64）\n- 繰り返される文字列にはLowCardinalityを使用\n- カテゴリカルデータにはEnumを使用\n\n### 4. 避けるべき\n- SELECT *（列を指定）\n- FINAL（代わりにクエリ前にデータをマージ）\n- JOINが多すぎる（分析用に非正規化）\n- 小さな頻繁な挿入（代わりにバッチ処理）\n\n### 5. モニタリング\n- クエリパフォーマンスを追跡\n- ディスク使用量を監視\n- マージ操作をチェック\n- 低速クエリログをレビュー\n\n**注意**: ClickHouseは分析ワークロードに優れています。クエリパターンに合わせてテーブルを設計し、挿入をバッチ化し、リアルタイム集計にはマテリアライズドビューを活用します。\n",{"name":5,"description":7},"main","57e7aa6b6e03bce1a7d7862ba9c2ec312f7f19b5","src\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fja-JP\u002Fskills\u002Fclickhouse-io",0,"https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee","https:\u002F\u002Fwithcyril.me\u002F","Hi, I’m Julian Cyril D, a Computer Science and Business Systems student at PSNACET.\r\nI’m passionate about full-stack development, UI\u002FUX design, and building sma","2026-11-04 23:28:50",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Cyrilthetecchieee\u002Fcyril-code- --skill clickhouse-io",{"tool":39,"command":40},"bunx","bunx skills add Cyrilthetecchieee\u002Fcyril-code- --skill clickhouse-io",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Cyrilthetecchieee\u002Fcyril-code- --skill clickhouse-io","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fdocs\u002Fja-JP\u002Fskills\u002Fclickhouse-io\u002FSKILL.md",true,[],[48,57,64,72,79,86],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":53,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7AQV6CYX8RMC78420V9WZ62","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7AQV2895N3S1MEX6K76G6G2","youtube-downloader","Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fvideo-downloader\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":68,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7AQTRNX62DNKVZ5GXEHRBKB","theme-factory","Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors\u002Ffonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftheme-factory\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftheme-factory\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":19},"01M7AQTNNVHAAN9H6DA8T6ZVE0","template-skill","Replace with description of the skill and when Claude should use it.","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftemplate-skill\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7AQTJ3MQ6AKX152MEX2MYCC","tailored-resume-generator","Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Ftailored-resume-generator\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":52,"licenseFileUrl":90,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M7AQTD7D5MYET2YWG7HG9WM3","slack-gif-creator","Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives. This skill applies when users request animated GIFs or emoji animations for Slack from descriptions like \"make me a GIF for Slack of X doing Y\".","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fslack-gif-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FCyrilthetecchieee\u002Fcyril-code-\u002Fblob\u002Fmain\u002Fsrc\u002Fcyril_code\u002Fassets\u002F.skills_repo\u002Fslack-gif-creator\u002FSKILL.md",[],[]]