skip to content

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 pageshow

questions

76 · 3 sections

In a columnar table, why does selecting 3 columns of 200 read far less data than SELECT *?

level: juniorimportance: must knowfreq 80%
basics
~20 s

Each 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.

open as a page

In a columnar table, how does a per-column encoding differ from a block codec like ZSTD?

level: juniorimportance: must knowfreq 50%
basics
~20 s

An 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.

open as a page

Why is inserting rows one at a time into a columnar analytical table so much worse than batching?

level: juniorimportance: must knowfreq 70%
basics
~20 s

Columnar 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.

open as a page

In a columnar engine, what is a zone map and how does it let a query skip data?

level: juniorimportance: must knowfreq 72%
basics
~20 s

A 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.

open as a page

Why does loading a columnar table in sorted order shrink it far more than loading it randomly?

level: middleimportance: must knowfreq 65%
basics
~20 s

Sorting 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.

open as a page

In a cloud data warehouse, what does separating storage from compute actually mean?

level: juniorimportance: must knowfreq 76%
basics
~20 s

Table 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.

open as a page

What is the difference between a data warehouse and a data lake for analytical data?

level: juniorimportance: must knowfreq 76%
basics
~20 s

A 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.

open as a page

In an MPP analytical warehouse, why can capping the number of concurrently running queries increase total throughput?

level: middleimportance: must knowfreq 68%
basics
~20 s

A 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.

open as a page

In an MPP query plan, what is an exchange operator and when must the planner insert one?

level: middleimportance: must knowfreq 74%
basics
~20 s

An 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.

open as a page

In a cloud warehouse, why is the first query after a suspended compute cluster resumes slower than later runs?

level: middleimportance: must knowfreq 68%
basics
~20 s

Resuming 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.

open as a page

How does APPROX_COUNT_DISTINCT differ from COUNT(DISTINCT) in an analytical engine?

level: juniorimportance: must knowfreq 60%
basics
~20 s

APPROX_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.

open as a page

Why is exact COUNT(DISTINCT) so expensive across an MPP warehouse, and how does HyperLogLog avoid it?

level: middleimportance: must knowfreq 65%
basics
~20 s

Exact 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.

open as a page

Why can a rollup table answer SUM queries directly but not AVG or COUNT(DISTINCT user_id)?

level: middleimportance: must knowfreq 58%
basics
~20 s

SUM, 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.

open as a page

What determines how much a pre-aggregated rollup table reduces the data an analytical query scans?

level: middleimportance: must knowfreq 62%
basics
~20 s

A 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.

open as a page

When joining a huge fact table to a small dimension, why does an MPP engine broadcast the dimension?

level: middleimportance: must knowfreq 72%
basics
~20 s

Broadcasting 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.

open as a page