# BigQuery for system design interviews

> BigQuery is Google Cloud's managed analytical data warehouse for SQL queries over large datasets. In a system design, it usually handles historical analysis, reporting, and event aggregation, while a separate database serves transactional requests.

Source: https://sysround.com/tech/bigquery
Updated: 2026-11-05


## How it works

BigQuery separates durable storage from query compute. Native table data lives in Google's distributed storage system, Colossus, in a columnar format that supports nested and repeated fields. Queries can read the columns they need rather than fetching complete rows.

The query engine uses a distributed execution architecture derived from Dremel. A query becomes stages that scan data, filter rows, join inputs, and aggregate results across workers. Large joins and GROUP BY operations often require a shuffle that redistributes intermediate data by key.

Compute capacity is measured in slots, which represent units of query execution resources rather than dedicated machines. BigQuery schedules work across slots and can adjust parallelism during execution. Reservations and edition-based autoscaling let teams allocate capacity and isolate workloads; on-demand pricing instead charges primarily for bytes processed.

Partitioning and clustering reduce how much data workers scan. Partitioning divides a table by a supported date, timestamp, or integer-range key, while clustering organizes storage blocks by selected columns. Eligible predicates let the engine prune partitions and blocks, but these are not substitutes for transactional database indexes.

Data enters through batch loads, SQL transformations, change-data-capture pipelines, or streaming APIs such as the Storage Write API. In a typical design, an event log absorbs ingestion bursts, stream processors produce low-latency views, and BigQuery retains detailed events for exploration and reconciliation. The durable event log is a separate component, not a role BigQuery replaces.

## What it gives you in a design

- **Columnar SQL analytics.** BigQuery supports large scans, joins, aggregations, and window functions without managing a database cluster. It fits questions that examine many records, not a request path dominated by single-row reads and writes.
- **Partitioning and clustering.** Time partitioning works well for event data, while clustering can improve pruning for filters such as tenant_id or campaign_id. Choose keys from actual query patterns and consider requiring partition filters to prevent accidental full-history scans.
- **Batch and streaming ingestion.** Batch loads suit periodic imports and backfills; the Storage Write API supports continuously arriving records. Freshness, retry behavior, and deduplication depend on the ingestion method and stream configuration.
- **Materialized views and precomputation.** Materialized views can accelerate supported query patterns, and eligible queries can reuse their results through automatic rewriting. Scheduled aggregate tables provide more transformation flexibility, at the cost of explicit refresh logic and freshness lag.
- **Workload and cost controls.** Reservations separate capacity for workloads such as dashboards and exploratory queries. Dry runs, maximum bytes billed, quotas, and partition filters help control cost, but predictable dashboard latency still requires capacity planning and appropriate query shapes.
- **Analytical transactions and access controls.** BigQuery supports atomic statements and multi-statement transactions with snapshot isolation, plus row-level and column-level access controls. These capabilities do not make it a good replacement for a high-concurrency transactional database.

## Scaling, replication and failure

Storage scales independently of query capacity. Partitioning primarily enables data pruning and management; it is not an application-managed sharding scheme in which the client routes each request to a database server. Clustering further reduces scans when filters match the organization of storage blocks.

Query speed depends on more than table size. Slot availability, concurrent workloads, shuffle volume, join expansion, and skew can dominate execution time. More slots do not automatically fix a single oversized aggregation group or an unnecessarily large intermediate result.

BigQuery maintains redundant storage across zones within a dataset's location. A multi-region location does not, by itself, promise automatic cross-region disaster recovery. Cross-region dataset replication and managed disaster recovery are separate capabilities whose availability and failover behavior must be checked for the chosen configuration.

Queries read consistent snapshots, but pipeline freshness is a separate concern: an event still waiting in a queue is absent from the warehouse. Atomic publication also does not prevent duplicates from producer retries. Define ingestion delivery guarantees, stable event IDs, deduplication, and how late events revise previously published aggregates.

## Limits and defaults worth knowing

- **Partitions per table:** A partitioned table supports up to 10,000 partitions. Choose partition granularity and retention together.
- **Clustering columns:** A table can have up to four clustering columns. Their order matters for pruning effectiveness.
- **Time travel window:** The time travel window is configurable from 2 to 7 days, with a default of 7 days. It is not a substitute for a broader backup and disaster recovery strategy.
- **Query result cache:** Cached query results are typically retained for about 24 hours on a best-effort basis. Eligibility and invalidation rules apply, so cache hits are not a latency guarantee.
- **Key constraints:** Declared primary key and foreign key constraints are not enforced. The ingestion pipeline must preserve any uniqueness and referential integrity the design requires.

## Use it when

- The design needs historical SQL analysis over large event datasets, with flexible joins and aggregations.
- Analysts need a warehouse that scales without application-managed shards or database servers.
- Operational traffic must be isolated from expensive reporting and exploratory queries.
- You need to reconcile low-latency stream aggregates against detailed historical events.
- Workload capacity, data freshness, and query cost can be managed separately from the transactional serving path.

## Avoid it when

- The core workload requires predictable millisecond point reads or high-QPS transactional updates.
- Correctness depends on enforced uniqueness, foreign keys, or frequent contention over individual records.
- Every incoming event must immediately trigger low-latency processing or an external side effect.
- The application needs a high-concurrency serving API with tight tail-latency guarantees and no precomputed serving layer.

## What interviewers ask about it

### How would you keep query costs under control?

Partition around common time filters, cluster around useful selective predicates, and select only needed columns. Use dry runs and maximum bytes billed for on-demand queries, or reservations and workload isolation for capacity-based operation. LIMIT alone usually does not reduce bytes scanned.

### How would you ingest events without double-counting retries?

Give events stable IDs and make deduplication explicit in the pipeline or warehouse transformations. The Storage Write API supports exactly-once writes within a stream when using supported stream types and offsets, but that does not deduplicate business events submitted independently to different streams.

### Would you query BigQuery directly for a customer dashboard?

It can work when query latency, concurrency, and cost fit the product requirements. For strict low-latency or high-QPS dashboards, precompute aggregates and serve them from a cache or analytical serving database, leaving BigQuery for historical analysis and reconciliation.

### How do you handle late events and corrected source data?

Partition using an explicit event-time or ingestion-time policy and define which historical periods can change. Recompute affected aggregates or apply idempotent MERGE operations, while exposing a freshness watermark so users know which results remain provisional.

### What do you inspect when a query becomes slow?

Check the execution graph for excessive scans, large shuffles, skew, join expansion, and slot contention. Improve pruning, reduce intermediate data, or preaggregate before assuming more compute is the answer.

### Can BigQuery be the source of truth for payments or inventory?

Keep authoritative transactional state in a database designed for those updates, then replicate changes into BigQuery for analysis. BigQuery supports transactions, but its execution model and unenforced key constraints are poor fits for a contention-heavy operational ledger or seat-allocation path.

## Common mistakes

- Calling BigQuery a key-value database or placing it directly on every latency-sensitive application request.
- Assuming partitioning guarantees cheap queries even when SQL does not contain a predicate that enables partition pruning.
- Treating successful ingestion or declared primary keys as proof that business events cannot be duplicated.
- Assuming a multi-region dataset automatically provides cross-region failover, or that adding slots fixes every slow query.

## Alternatives

- **Snowflake:** A managed warehouse with independently sized virtual warehouses and support across multiple cloud providers better matches the organization's platform and workload-isolation requirements.
- **Amazon Redshift:** The surrounding platform is AWS-centric and the team wants a managed analytical warehouse integrated with that ecosystem.
- **ClickHouse:** The primary requirement is low-latency, high-concurrency analytics over well-understood query patterns, and the team can choose or operate an appropriately sized serving deployment.
- **Trino over object storage:** Open table formats, direct control of lake storage, and querying across multiple data sources matter more than having one integrated managed warehouse.

## Interview questions where it comes up

- [Design Google Analytics](https://sysround.com/questions/design-google-analytics): BigQuery fits historical event exploration, session analysis, and distinct-user reporting after retry-safe ingestion.
- [Design an ad click aggregator](https://sysround.com/questions/design-ad-click-aggregator): It provides a historical analytical layer for reconciling provisional stream counts with deduplicated events and late corrections.
- [Design an A/B testing platform](https://sysround.com/questions/design-ab-testing-platform): It supports warehouse queries that join experiment assignments, exposures, and outcomes for trustworthy experiment analysis.
- [Design a metrics monitoring system like Datadog](https://sysround.com/questions/design-metrics-monitoring-system): It can support long-term analytical reporting over exported metrics while a separate time-series system handles live dashboards and alert evaluation.

## FAQ

### What is BigQuery's architecture?

BigQuery separates distributed columnar storage from distributed SQL execution. Colossus stores table data, while a Dremel-derived engine executes query stages using slots and exchanges intermediate data through shuffle. Partitioning and clustering help reduce the data those stages must read.

### Is BigQuery an OLTP or OLAP database?

BigQuery is primarily an OLAP system for analytical scans, joins, and aggregations. It supports DML and transactions, but that does not make it a good fit for frequent single-record updates, enforced uniqueness, or low-latency transactional serving.

### What is the difference between partitioning and clustering in BigQuery?

Partitioning divides a table into segments based on a supported partition key, allowing eligible queries to skip entire partitions. Clustering organizes blocks within a table or partition using selected columns, enabling additional block pruning. They can be combined, and their value depends on the filters your queries actually use.

## Related concepts

- [Columnar storage](https://sysround.com/concepts/columnar-storage)
- [Partitioning strategies](https://sysround.com/concepts/data-partitioning)
- [Materialized views](https://sysround.com/concepts/materialized-views)
- [Change data capture](https://sysround.com/concepts/change-data-capture)
- [CQRS](https://sysround.com/concepts/cqrs)


---
SysRound (https://sysround.com) is an AI practice tool for system design interviews: a voice or typed AI interviewer, a shared whiteboard, then feedback on every skill and a model answer. Its feedback is AI-generated and can be wrong.
