Skip to content

Diogo TravassosData leadership · Analytics · Decision-making

Real public data

What cuts a BigQuery bill on a dbt model of web analytics events

On three dated held-out queries, the one-line date filter cut scanned data by a median 80%, against 87% before.

What was tested

The first six queries picked the winner. A fair test needs queries that played no part in that. Four more were written and frozen in the design, before any query ran. They were run once the first results were in, three times each with the cache off, on the same layouts.

The test applied the two best changes where they fit without a new model: the one-line date filter and the table copy. The rule, set in advance: the filter's gain holds if its median saving on these queries is at least half its median on the first six.

The result

It held. The filter saved a median 80%, against 87% before, a ratio of 0.92. The bar was 0.5. Slot time fell 48% to 80%.

The one-line filter cut bytes on each held-out query that reads a date window.

Share of bytes billed saved by the filter, median of 3 runs

  1. Revenue per session by landing page last 30 days, 1,558 to 410 MiB74%
  2. Add-to-cart rate by item category last 21 days, 171 to 34 MiB80%
  3. Daily engaged sessions by country last 7 days, 1,520 to 92 MiB94%

The table copy held too: a median 86% against 87% before.

The weekly new-against-returning query reads every day, so the filter has nothing to skip. The add-to-cart query reads the items view, which has no table copy.

Every held-out query gave the same answer on every layout.

Every held-out run

Bytes billed, slot time and elapsed time, median of three runs per layout.

Held-out queries by layout
QueryLayoutMiB billedSlot secondsElapsed seconds
New against returning users by week, all 92 daysStaging view, as built1,47268.023.52
Copied into a table1186.380.80
Table partitioned by date1182.230.59
Partitioned and clustered by event name1181.960.47
Revenue per session by landing page, last 30 daysStaging view, as built1,55832.913.28
Same view, one-line date filter41017.181.51
Copied into a table4988.790.88
Table partitioned by date1362.770.39
Partitioned and clustered by event name1363.080.36
Add-to-cart rate by item category, last 21 daysStaging view, as built1713.182.06
Same view, one-line date filter340.930.89
Daily engaged sessions by country, last 7 daysStaging view, as built1,52021.042.60
Same view, one-line date filter924.271.06
Copied into a table2101.660.25
Table partitioned by date140.260.16
Partitioned and clustered by event name140.230.14

Limits

Four queries is a small test. They come from the same model and the same 92 days, so they test whether the gain carries to new questions, not to new data. The marts did not carry: each was built for its own tile.

The held-out queries were written with the first six, and their date ranges, 7 to 30 days, are like theirs. The filter's cut is roughly the share of days a query skips, so a query reading more of the history would gain less. So the filter's result here confirms that arithmetic on new questions. It is not independent evidence: a test on a longer history would be. The table copy's gain does not depend on the range.