Lewati ke konten utama

← ~/writing · 13 Oktober 2026 · 1 mnt baca

The Postgres indexes I add on day one

Every table I create gets the same three questions before it gets data.

Most slow queries I have fixed were missing an index that the access pattern made obvious on day one.

Owner first

In multi-tenant tables, every query filters by owner. Lead the index with it.

create index on project (user_id, status);

Order by what you sort

If a list is always newest first, the index should say so.

Bagikan: