BigQuery cost query · Slots and billing model
On-demand vs editions: which is cheaper per project
This query compares what each project's queries cost on-demand with what the same slot-hours would cost on Standard and Enterprise editions, using 30 days of INFORMATION_SCHEMA data, and adds the GiB scanned per slot-hour that decides the answer.
The query
SELECT
project_id,
ROUND(SUM(total_bytes_billed) / POW(1024, 4), 2) AS tib_billed,
ROUND(SUM(total_slot_ms) / 3600000, 1) AS slot_hours,
ROUND(SUM(total_bytes_billed) / POW(1024, 4) * 6.25, 2) AS on_demand_usd,
ROUND(SUM(total_slot_ms) / 3600000 * 0.04, 2) AS standard_payg_usd,
ROUND(SUM(total_slot_ms) / 3600000 * 0.06, 2) AS enterprise_payg_usd,
ROUND(SAFE_DIVIDE(SUM(total_bytes_billed) / POW(1024, 3),
SUM(total_slot_ms) / 3600000), 1) AS gib_per_slot_hour
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_ORGANIZATION
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
AND job_type = 'QUERY'
AND statement_type != 'SCRIPT'
GROUP BY project_id
ORDER BY on_demand_usd DESC;How it works
On-demand charges for bytes; editions charge for slot-hours. BigQuery records both for every job, whichever model the project uses (for projects on a reservation, total_bytes_billed is informational), so the same 30 days can be priced both ways.
In the US, an Enterprise slot-hour at $0.06 costs the same as scanning about 9.8 GiB on-demand, and a Standard slot-hour at $0.04 the same as about 6.6 GiB. Projects whose gib_per_slot_hour is well above that are cheaper on editions; projects well below it are cheaper on-demand. You can mix both by assigning only some projects to a reservation.
Output columns
| Column | Meaning |
|---|---|
on_demand_usd | List price of the bytes billed at $6.25 per TiB, before the monthly free TiB. |
standard_payg_usd | Slot-hours at the Standard pay-as-you-go price. |
enterprise_payg_usd | Slot-hours at the Enterprise pay-as-you-go price. |
gib_per_slot_hour | GiB scanned per slot-hour: the number that decides which model is cheaper. |
Permissions and notes
Needs: bigquery.jobs.listAll on the organization, for example the BigQuery Resource Viewer role (roles/bigquery.resourceViewer) granted at the organization level.
- The editions columns are a lower bound: autoscaled slots are billed in steps of 50 and for at least a minute unless fluid scaling is on, so a reservation bills more slot-hours than jobs report. Add the overhead you see in practice, for example in the pricing calculator.
- Standard edition lacks BigQuery ML, BI Engine, customer-managed keys and fine-grained security; check that a project doesn't need them before moving it.
- Replace
region-uswith your location. Each region has its own INFORMATION_SCHEMA views.
FAQ
Can one organization use both on-demand and editions?
Yes. Billing is decided per project: projects assigned to a reservation use editions, the rest stay on-demand.
Do commitments change the answer?
They lower the slot-hour price (for Enterprise, $0.048 for one year and $0.036 for three as slot commitments in the US) but bill every hour of the term, so they only pay off for slots you keep busy.
Related
All BigQuery cost queries · Data FinOps playbook · Pricing calculator
