21. BigQuery — Dremel and serverless SQL
One-liner. Columnar storage plus a tree of compute nodes makes "scan a trillion rows" interactive.
Context. Ad-hoc SQL over enormous append-only event tables, with unpredictable concurrency.
Public architecture (Dremel paper, 2010).
- Columnar storage with nested/repeated fields encoded as definition/repetition levels.
- Query execution is a multi-level serving tree: root → intermediate → leaf shards, each scanning a fraction.
- Slots abstract compute; on-demand pricing bills bytes scanned, capacity pricing reserves slots.
- Streaming inserts land in a buffer before compaction into columnar storage; BI Engine adds an in-memory acceleration layer.
Design lesson. Price on bytes scanned, then partitioning and clustering become the main cost controls. Columnar layout is what makes wide tables cheap.
Trade-off. SELECT * on an unpartitioned table is a budget incident; denormalized wide tables are cheap to scan but expensive to update.
Trap. Optimizing for row count instead of bytes scanned — a wide table with few rows can cost more. Do this. Partition by date, cluster by the filter column, select only needed columns.
In a bytes-scanned warehouse, which change most directly reduces query cost?
Cost follows bytes read; pruning partitions and columns is the direct lever.