query-optimization
Installation
SKILL.md
Query Optimization
JOIN Strategies
join_algorithmsetting:hash(default, in-memory),partial_merge(spills to disk for large right table),auto(lets ClickHouse decide)JOIN ... USINGavoids repeated column names vsONfor same-name columns- Filter both sides before joining to reduce intermediate data
GLOBAL JOINbroadcasts the right table to all shards for distributed queries
EXPLAIN Analysis
EXPLAIN PLAN— logical plan, shows projection/pushdown transformationsEXPLAIN PIPELINE— physical execution with parallelism info and port countsEXPLAIN INDEXES— which indexes fire, granules selected vs total- Look for: full table scans, missing index usage, excessive granule reads