BigQuery Cost Optimization: On-Demand vs Slot Commitments
The beauty of BigQuery is that it requires no infrastructure management. The danger is that an analyst can accidentally spend $500 with a single SELECT * query.
Situation
Data teams initially love BigQuery’s on-demand pricing model ($5 to $6.25 per TB scanned). It allows them to start small without upfront capacity planning.
The Problem
As data volume grows and user adoption increases, on-demand costs become unpredictable and highly volatile. A poorly written query without a WHERE clause on a massive unpartitioned table scans petabytes of data, causing immediate budget overruns. How do you secure BigQuery costs without bottlenecking the data team?
The Optimization Checklist
- Enforce Partition Filters: Require partition filters on all multi-terabyte tables at the schema level.
- Materialized Views: Pre-aggregate common daily/weekly metrics so dashboards aren’t scanning raw event data.
- Query Limits: Set maximum bytes billed limits per user and per project to prevent accidental runaway queries.
- Transition to Capacity Pricing: Evaluate moving from On-Demand to Capacity Pricing (Slot Commitments).
In Practice
The documented pattern for mature BigQuery environments is a hybrid approach. They purchase baseline slot commitments (e.g., 500 slots) to handle predictable, continuous ETL workloads, while keeping ad-hoc analyst exploration on the on-demand model with strict query limits enforced.
Where It Breaks
| Strategy | Tradeoff |
|---|---|
| Slot Commitments | Purchasing slots caps your maximum spend, but it also caps your maximum performance. If multiple analysts run heavy queries simultaneously, queries will queue and latency will increase. |
| Partition Enforcement | Hard-enforcing partition filters breaks legacy queries and dashboards that were built assuming full table scans were acceptable. |
What to Do Next
- Problem: Volatile and unpredictable BigQuery on-demand costs.
- Solution: Implement table partitioning, enforce query limits, and evaluate baseline slot commitments.
- Proof: Transitioning baseline ETL to capacity pricing while restricting ad-hoc scans consistently flattens BigQuery spend curves.
- Action: Audit your
INFORMATION_SCHEMA.JOBSto identify the top 10 most expensive queries this week.