0
0
GcpComparisonBeginner · 4 min read

On Demand vs Flat Rate BigQuery: Key Differences and Usage

In BigQuery, 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.

FactorOn Demand PricingFlat Rate Pricing
Cost ModelPay per data scanned in queriesFixed monthly fee for slots (processing units)
Billing UnitBytes scanned per querySlots allocated per month
Best ForIrregular or low query volumeConsistent, high query volume
PerformanceShared resources, variable speedDedicated resources, stable speed
Cost PredictabilityVariable, depends on usagePredictable monthly cost
Setup ComplexityNo setup neededRequires 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):

python
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}")
Output
James: 438932 John: 423648 Robert: 410909 Michael: 399943 William: 381214
↔️

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:

python
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}")
Output
James: 438932 John: 423648 Robert: 410909 Michael: 399943 William: 381214
🎯

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.

Key Takeaways

On Demand pricing charges per data scanned and suits variable workloads.
Flat Rate pricing offers fixed monthly cost with dedicated query slots for steady workloads.
Performance is more consistent with Flat Rate due to reserved resources.
On Demand requires no setup; Flat Rate needs slot purchase and management.
Choose pricing based on your query volume, cost predictability, and performance needs.