Skip to content
Finitizer

What a SELECT * view costs in BigQuery

A SELECT * view bills only the columns each query takes from it.

It costs extra when readers select every column, as BI tools often do.

Check one of your own queries for this

Paste a query and the analyzer estimates what it scans and flags the patterns it can detect statically. It runs in your browser.

What it is

A logical view is expanded into the query that references it, and BigQuery bills the columns the top-level query uses, directly or through the view. So SELECT user_id FROM a SELECT * view bills user_id alone. The cost arrives when the reader selects everything too: SELECT * FROM the view, or a BI tool that pulls every field.

Why it costs money

  • Readers tend to treat a view as a table and select all of it, BI tools and extracts especially. Then every column of the underlying table is read, including ones the view never needed to expose.
  • A SELECT * view changes shape whenever the table does: a new large JSON column appears in the view, and in every SELECT * over it, with no change to anyone's SQL.
  • Nested views hide what a query reads. Nobody reads three levels of definitions before writing a query.

Worked example

Expensive
CREATE VIEW `analytics.v_events` AS
SELECT * FROM `analytics.events_raw`
Cheaper
CREATE VIEW `analytics.v_events` AS
SELECT event_id, user_id, event_name, event_timestamp, event_date
FROM `analytics.events_raw`
The arithmetic. On a 2 TiB table, SELECT user_id FROM v_events bills the ~8 GiB that column occupies ($0.05) through either view. SELECT * FROM v_events, the query a BI extract sends, bills the whole 2 TiB ($12.50) through the first view and the five listed columns, ~50 GiB ($0.31), through the second.

How to fix it

  1. 1Enumerate columns in view definitions: the view keeps a stable shape, and what it can cost is clear from its definition.
  2. 2Point BI tools and extracts at views that expose only the columns they need, since they tend to select everything.
  3. 3Audit view definitions with INFORMATION_SCHEMA.VIEWS and search for SELECT *.
  4. 4Prefer authorized views with an explicit column list where the view exists for access control.
No single query reveals this one. It shows up across job history instead, the query pack has recipes that find it.

Fixing one query is satisfying. Fixing the pattern is the win.

Finitizer finds every instance of this across your BigQuery job history, ranks them by what they actually cost, and keeps checking after you have fixed them.

See how Finitizer works