Google BigQuery (50 Qs)•Part 3: Enterprise FinOps, Disaster Recovery & Scale (25 - 35)
Partitioning vs Clustering in BigQuery: Architectural differences and best practices.
senior LevelCode ExamplebigqueryEnterprise FinOps
In Simple Words:
- Partitioning: Divides a table into physical date/timestamp, ingestion-time, or integer range segments (up to 4,000 partitions):
sql
CREATE TABLE orders (id INT64, order_date DATE, amount NUMERIC) PARTITION BY order_date OPTIONS (require_partition_filter = true);- Queries filtering by
order_dateskip unneeded partition files entirely, reducing billed scan bytes to near zero.
- Queries filtering by
- Clustering: Sorts and colocates rows within each partition by up to 4 columns (
CLUSTER BY customer_id, status):- Capacitor groups identical cluster keys into adjacent data blocks.
- Unlike partitioning, clustering has no physical segment limit and handles high-cardinality keys effortlessly.