Field note · March 14, 2023

We saved $2,100 a month by typing more

A columnar storage lesson learned from a bill, not a book.

1 min read ·Data platform ·performance warehousing

Our warehouse bill went up 40% in a quarter with no obvious cause. Data volume was up maybe 8%.

The cause was a dashboard. One dashboard, refreshing every fifteen minutes, backed by a query that started select * from fct_events. The table has 74 columns. The dashboard used four of them.

On a columnar warehouse, select * reads every column's storage block off disk. Naming four columns reads four. We were paying roughly 18 times what the dashboard needed, 96 times a day, whether or not anyone had it open.

The fix took two minutes:

sql
-- before: reads all 74 columns
select * from fct_events where event_date >= current_date - 7;

-- after: reads 4
select event_date, user_id, event_type, revenue_usd
from fct_events where event_date >= current_date - 7;

$2,100 a month.

Two things I have said too often since:

select * is not sloppy style on a warehouse, it is an instruction to read everything. In Postgres it costs you almost nothing. In Snowflake, BigQuery or Redshift it is the single most expensive habit available.

Nobody is watching the bill by query. We now review the top ten by spend monthly. It takes fifteen minutes and it has never once found nothing.

The second one is the actual lesson. The first was in the documentation the whole time.