Request a demo

BigQuery cost query · Waste

Find SELECT * queries that scan whole tables

This query finds the most expensive queries that start with SELECT FROM in the last 30 days, grouped by principal. BigQuery bills every column a query touches, so SELECT on a wide table is often the single most expensive habit, and LIMIT doesn't help.

Runs on INFORMATION_SCHEMA metadata only · Columns checked against the Google Cloud docs in November 2026

The query

SELECT
  user_email,
  COUNT(*)                                                AS queries,
  ROUND(SUM(total_bytes_billed) / POW(1024, 4), 2)        AS tib_billed,
  ROUND(SUM(total_bytes_billed) / POW(1024, 4) * 6.25, 2) AS est_on_demand_usd,
  ANY_VALUE(LEFT(query, 200))                             AS example_query
FROM `region-us`.INFORMATION_SCHEMA.JOBS
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
  AND job_type = 'QUERY'
  AND statement_type != 'SCRIPT'
  AND REGEXP_CONTAINS(query, r'(?i)select\s+\*\s+from')
GROUP BY user_email
ORDER BY est_on_demand_usd DESC;

How it works

BigQuery stores tables by column and bills on-demand queries for every byte of every column they read. SELECT * reads all of them, and a LIMIT 10 at the end changes the rows returned, not the bytes billed. The table preview in the console and bq head show sample rows for free.

The pattern also matches SELECT * FROM over a CTE or subquery that has already selected a few columns, which costs nothing extra. Look at example_query and the bytes billed before you chase a principal.

Output columns

ColumnMeaning
tib_billedTiB billed by the matching queries.
example_queryOne matching query, to see whether the * is on a base table.

Permissions and notes

Needs: bigquery.jobs.listAll on the project, for example through the BigQuery Resource Viewer role (roles/bigquery.resourceViewer).

  • The 6.25 is the on-demand list price per TiB in the US and EU multi-regions; see BigQuery pricing for editions and other regions.
  • SELECT * EXCEPT (...) doesn't match the pattern and can still read most columns; search for it separately if your team uses it on wide tables.

FAQ

Does LIMIT reduce BigQuery cost?

No. On-demand cost depends on the columns read, not the rows returned. Select fewer columns, or filter on partition and cluster columns.

How do I look at a table's data for free?

Use the Preview tab in the console or bq head, which read rows without running a query.

All BigQuery cost queries · Data FinOps playbook · Pricing calculator

Cut BigQuery spend without guessing

Masthead attributes compute and storage cost to every project, user, pipeline and table, finds unused and dead-end tables, and shows where editions or on-demand pricing is cheaper. Mnemonic cut its BigQuery compute cost by 20% within 24 hours of onboarding.