
Your BigQuery bill jumped. Was it one expensive query, or did a scheduled job quietly start scanning more data? Start with BigQuery’s job history. Two SQL queries can show you which days drove the increase and which jobs to investigate first.
This guide estimates on-demand query compute costs. BigQuery reservations use capacity-based pricing, so multiplying billed bytes by a price per tebibyte (TiB) is not a way to price reservation usage.
Before you run the SQL
- Select the project that ran the jobs.
INFORMATION_SCHEMA.JOBS_BY_PROJECTis project-scoped. You need permission to run a query and list the project’s jobs, not just your own. - Match the query location. The examples use the EU multi-region. If your jobs ran in the US multi-region, replace
region-euwithregion-usand run the SQL in the US. A single region such aseurope-west1is not the same as the EU multi-region. If you use multiple locations, check them separately. - Set your rate. Replace
6.00in both examples with the applicable USD price per TiB from BigQuery pricing. The example rate is illustrative, not a quote. Usetotal_bytes_billed, nottotal_bytes_processed, for the estimate.
Estimate daily query costs for the last 30 days
This query groups jobs by the UTC date they started, covers 30 complete UTC days, and omits days with no matching usage. It excludes multi-statement script parents so their child jobs aren’t counted twice, and skips jobs with a recorded reservation.
WITH daily AS (
SELECT
DATE(creation_time, 'UTC') AS job_date_utc,
COUNT(*) AS billed_query_jobs,
SUM(CAST(total_bytes_billed AS NUMERIC)) AS billed_bytes
FROM `region-eu`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP(DATE_SUB(CURRENT_DATE('UTC'), INTERVAL 30 DAY))
AND creation_time < TIMESTAMP(CURRENT_DATE('UTC'))
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type IS DISTINCT FROM 'SCRIPT'
AND reservation_id IS NULL
AND total_bytes_billed > 0
GROUP BY job_date_utc
)
SELECT
job_date_utc,
billed_query_jobs,
ROUND(billed_bytes / 1099511627776, 3) AS billed_tib,
-- Replace 6.00 with your on-demand price in USD per TiB.
ROUND(billed_bytes / 1099511627776 * NUMERIC '6.00', 2) AS estimated_usd
FROM daily
ORDER BY job_date_utc DESC;One TiB is 1,099,511,627,776 bytes. At an illustrative $6.00 per TiB, 3.25 TiB × $6.00 = $19.50 before free usage, credits, or discounts. The query rounds the estimate after adding up the day’s bytes.
Find the 20 most expensive query jobs from the last seven days
This query ranks individual jobs by billed bytes, not by their rounded dollar estimate. Use the job ID to find the query in BigQuery’s job history. The user email can help you identify the person or service account that submitted it.
SELECT
creation_time,
job_id,
user_email,
total_bytes_billed AS billed_bytes,
ROUND(CAST(total_bytes_billed AS NUMERIC) / 1099511627776, 3) AS billed_tib,
-- Replace 6.00 with your on-demand price in USD per TiB.
ROUND(CAST(total_bytes_billed AS NUMERIC) / 1099511627776
* NUMERIC '6.00', 2) AS estimated_usd
FROM `region-eu`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 7 DAY)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type IS DISTINCT FROM 'SCRIPT'
AND reservation_id IS NULL
AND total_bytes_billed > 0
ORDER BY billed_bytes DESC, creation_time DESC, job_id
LIMIT 20;If the same workload appears repeatedly, look for a missing partition filter, unnecessary columns, or a schedule that runs more often than needed. After rewriting a query, use a dry run and a maximum-bytes-billed limit to check and cap on-demand usage before you run it again.
Check the estimate against Cloud Billing
Open Cloud Billing Reports, select the same project and date range, filter to BigQuery, and group by SKU. Compare with the on-demand query analysis charges, not the total BigQuery bill. Free usage, credits, discounts, and reporting time boundaries can all make the numbers differ. Storage, streaming ingestion, and capacity charges are outside this calculation. Jobs with no recorded billed bytes, including some queries against tables with row-level access policies, won’t appear in the SQL results.
Use Cloud Billing to see what you paid. Use job history to see which queries are worth fixing.
