On Demand vs Flat Rate BigQuery: Key Differences and Usage
On Demand pricing charges you based on the amount of data scanned per query, while Flat Rate pricing charges a fixed monthly fee for dedicated query processing capacity. Choose On Demand for unpredictable or low query volumes, and Flat Rate for steady, high-volume workloads.Quick Comparison
Here is a quick side-by-side comparison of On Demand and Flat Rate pricing in BigQuery.
| Factor | On Demand Pricing | Flat Rate Pricing |
|---|---|---|
| Cost Model | Pay per data scanned in queries | Fixed monthly fee for slots (processing units) |
| Billing Unit | Bytes scanned per query | Slots allocated per month |
| Best For | Irregular or low query volume | Consistent, high query volume |
| Performance | Shared resources, variable speed | Dedicated resources, stable speed |
| Cost Predictability | Variable, depends on usage | Predictable monthly cost |
| Setup Complexity | No setup needed | Requires slot purchase and management |
Key Differences
On Demand pricing charges you only for the data your queries scan. This means if you run few or small queries, you pay less. However, costs can spike if queries scan large amounts of data unexpectedly. Performance depends on shared resources, so query speed can vary.
Flat Rate pricing lets you buy dedicated query processing capacity called slots. You pay a fixed monthly fee regardless of how much data you scan. This gives you predictable costs and stable performance because your queries use reserved resources. It is ideal for organizations with steady, heavy query workloads.
Choosing between them depends on your usage pattern. On Demand is simple and flexible with no upfront commitment. Flat Rate requires planning and management but offers cost control and consistent speed for large-scale analytics.
Code Comparison
Example of running a simple query using On Demand pricing (default in BigQuery client):
from google.cloud import bigquery client = bigquery.Client() query = "SELECT name, COUNT(*) as count FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY count DESC LIMIT 5" query_job = client.query(query) # On Demand pricing by default results = query_job.result() for row in results: print(f"{row.name}: {row.count}")
Flat Rate Equivalent
Using Flat Rate pricing requires purchasing slots in the Google Cloud Console or via API. The query code stays the same, but queries run on reserved slots for stable performance.
Here is the same query example; the difference is in billing setup, not code:
from google.cloud import bigquery client = bigquery.Client() query = "SELECT name, COUNT(*) as count FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY count DESC LIMIT 5" query_job = client.query(query) # Runs on Flat Rate slots if purchased and assigned results = query_job.result() for row in results: print(f"{row.name}: {row.count}")
When to Use Which
Choose On Demand pricing when:
- You have unpredictable or low query volumes.
- You want no upfront commitment or setup.
- You prefer paying only for what you use.
Choose Flat Rate pricing when:
- You run large, steady workloads with many queries.
- You want predictable monthly costs.
- You need consistent query performance with dedicated resources.