Analytical Database Concepts
How an analytical store behaves whatever product runs it: columnar layout, encodings and pruning, vectorized execution, MPP execution and shuffle, storage and compute kept apart, the warehouse-lake-lakehouse choice, workload isolation, and the query shapes analytics actually runs. Interviewers lean on this layer because it transfers when a candidate moves between warehouses — it separates people who can predict what a scan or a join will cost from people who have memorised one vendor's console. No product is taught here — a product appears only to illustrate a mechanism; the warehouse subtrees sit beside this one under db-analytical.
on this pageshowhide
explore
- Columnar Storage & Encoding29 questions
- Column Chunks & Late Materialization5 questions
- Encodings & Compression6 questions
- Zone Maps, Pruning & Clustering Keys6 questions
- Immutable Files, Compaction & Small Files6 questions
- Vectorized Execution6 questions
- MPP & Warehouse Architecture24 questions
- MPP Execution & Shuffle6 questions
- Separation of Storage & Compute6 questions
- Warehouse vs Lake vs Lakehouse6 questions
- Concurrency & Workload Isolation6 questions
- OLAP Query Patterns23 questions
- Star-Schema Join Strategies5 questions
- Window Functions at Scale6 questions
- Materialized Views & Incremental Refresh6 questions
- Approximate Aggregation & Sampling6 questions
- AI & Data Scientistroleanchors this topic
- BI Analystroleanchors this topic
- Data Analystroleanchors this topic
- Data Engineerroleanchors this topic
- MLOps Engineerroleanchors this topic
- Software Architectroleanchors this topic
- BigQueryskill
- ClickHouseskill
- Forward Deployed Engineerrole
- Server-Side Game Developerrole
- Snowflakeskill
questions
76 · 3 sectionsIn a columnar table, why does selecting 3 columns of 200 read far less data than SELECT *?
basics
~20 sEach column's values sit contiguously in their own chunks, and the file metadata records where every chunk starts. The scan reads only the byte ranges of the columns the query names; the other columns are never opened or decompressed.
In a columnar table, how does a per-column encoding differ from a block codec like ZSTD?
basics
~20 sAn encoding rewrites one column's values in a type-aware way — dictionary codes, run lengths, deltas — and can often be queried directly. A codec such as ZSTD then compresses those encoded bytes opaquely, and the block must be decompressed before anything can read it.
Why is inserting rows one at a time into a columnar analytical table so much worse than batching?
basics
~20 sColumnar engines write immutable files, and the smallest unit a write can produce is a whole file. One row per insert means millions of tiny files, terrible compression, metadata bigger than data, and a background merge queue that can never catch up.
In a columnar engine, what is a zone map and how does it let a query skip data?
basics
~20 sA zone map is small per-block metadata holding each column's minimum and maximum value in that block. Before reading a block, the engine tests the query's filter against those bounds and skips every block that cannot possibly contain a matching row.
Why does loading a columnar table in sorted order shrink it far more than loading it randomly?
basics
~20 sSorting puts equal values next to each other, so run-length encoding sees long runs and delta encoding sees small differences instead of noise. The same data can compress several times better sorted, and correlated columns downstream of the sort key gain too.
In a cloud data warehouse, what does separating storage from compute actually mean?
basics
~20 sTable data lives as files in a shared object store that every node can read over the network, and compute clusters are stateless workers that read it. Either side can be resized, paused or duplicated without touching the other.
What is the difference between a data warehouse and a data lake for analytical data?
basics
~20 sA data warehouse stores data in an engine-managed, usually proprietary format with an enforced schema and integrated compute. A data lake stores raw files in object storage that many engines can read, with structure applied only at query time.
In an MPP analytical warehouse, why can capping the number of concurrently running queries increase total throughput?
basics
~20 sA cluster has a fixed budget of memory, CPU and I/O. Past a point, extra concurrency splits that budget so thinly that queries spill to disk and contend for the same resources, so queueing the excess finishes more work per hour.
In an MPP query plan, what is an exchange operator and when must the planner insert one?
basics
~20 sAn exchange moves rows between compute nodes over the network. The planner inserts one wherever an operator needs matching key values on the same node and the current data placement does not already guarantee that — joins, grouping, global sorts, and the final gather.
In a cloud warehouse, why is the first query after a suspended compute cluster resumes slower than later runs?
basics
~20 sResuming provisions fresh worker VMs whose memory and local SSD caches are empty, so the first query reads everything remotely from object storage. Subsequent runs hit warm local caches and skip most of that network traffic.
How does APPROX_COUNT_DISTINCT differ from COUNT(DISTINCT) in an analytical engine?
basics
~20 sAPPROX_COUNT_DISTINCT returns an estimated number of distinct values computed from a small fixed-size sketch, rather than the exact number computed by tracking every value seen. It uses far less memory and time, at a few percent typical error.
Why is exact COUNT(DISTINCT) so expensive across an MPP warehouse, and how does HyperLogLog avoid it?
basics
~20 sExact distinct counting must bring every copy of a value onto one node and hold a hash table sized by cardinality, so it costs a shuffle plus memory that spills. HyperLogLog builds a fixed-size sketch per node and merges sketches with a per-register maximum.
Why can a rollup table answer SUM queries directly but not AVG or COUNT(DISTINCT user_id)?
basics
~20 sSUM, COUNT, MIN and MAX re-aggregate correctly because combining group results is the same operation again. AVG is a ratio, so store SUM and COUNT and divide at read time. Distinct counts and medians cannot be recombined at all from stored group results.
What determines how much a pre-aggregated rollup table reduces the data an analytical query scans?
basics
~20 sA rollup's win is base rows divided by the number of distinct grouping-key combinations that actually occur in the data. Coarse grain and low-cardinality keys win most; adding a near-unique key such as session_id saves almost nothing.
When joining a huge fact table to a small dimension, why does an MPP engine broadcast the dimension?
basics
~20 sBroadcasting sends one full copy of the small dimension to every node so each node joins its local fact rows without moving them. The fact table is orders of magnitude larger, so shipping the dimension costs far less network traffic than redistributing both sides.