Skip to the page
Tecyfy

SQL interview question · medium

Your team pays for BigQuery on demand. Finance asks whether a slot reservation would be cheaper. How do you answer with data?

The short answerCompare one ratio against a break-even: slot-hours used per TiB scanned.

The full answer

Compare one ratio against a break-even: slot-hours used per TiB scanned. On demand, 1 TiB costs $6.25 in the US. The same $6.25 buys 156 slot-hours on Standard edition ($0.04), 104 on Enterprise ($0.06) or 62.5 on Enterprise Plus ($0.10). If your queries use fewer slot-hours per TiB than that, slots are cheaper; if more, on-demand is. Measure the ratio from INFORMATION_SCHEMA.JOBS, then leave a margin, because a reservation bills the capacity it holds, not only what queries use.

1. Measure it

SELECT
  SUM(total_bytes_billed) / POW(1024, 4)                     AS tib_billed,
  SUM(total_slot_ms) / 3600000                               AS slot_hours,
  SAFE_DIVIDE(SUM(total_slot_ms) / 3600000,
              SUM(total_bytes_billed) / POW(1024, 4))        AS slot_hours_per_tib
FROM `region-us`.INFORMATION_SCHEMA.JOBS
WHERE job_type = 'QUERY'
  AND creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY);

Group it by user or service account too: one dashboard refreshing every few minutes can decide the answer alone.

2. Read the result

WorkloadSlot-hours per TiBCheaper
Wide scans, light filteringLow (for example 60)Editions
Heavy joins, window functions on little dataHigh (for example 200)On-demand

A month of 30 TiB and 2,000 slot-hours costs $181.25 on demand (29 billable TiB) against $80 on Standard: switch. A month of 200 TiB and 40,000 slot-hours costs $1,243.75 on demand against $1,600 on Standard: stay.

3. The margin

  • Autoscaling grows in steps of 50 slots and keeps them at least 60 seconds, so short queries pay for idle slots.
  • Baseline slots are billed every hour, busy or not.
  • Billing has a 1-minute minimum.

If slots win by 10% on paper, stay on demand. If they win by half, move, cap the autoscaler, and compare the first full bill with the estimate.

4. What helps either way

Partitioning and clustering cut bytes on demand and slot time on editions; do them first. See Data Partitioning and Clustering. The BigQuery cost calculator prices both models by region.

What interviewers want: the break-even derived from the 2 prices, measuring slot-hours per TiB from the JOBS view, an example on each side, the autoscaling and baseline overheads as a margin, and query tuning before buying capacity.

Last updated 22 October 2026