Track · 2:30 · Liner note
Sorted for a Rainy Day
A sort key defines the physical order of rows in storage, and choosing it well lets the engine skip large ranges of data and compress similar values together.
Row order on disk is a design decision. A sort key places similar rows next to each other, so a filter on those columns can skip most of the table and similar values compress better. Sorted for a Rainy Day is the forward-looking habit of ordering data for the queries you will be running when things get busy.
Put the columns you filter by most first, then test against real queries. The key is hard to change later, because it means rewriting the table, so spend an afternoon now rather than a weekend after.