Skip to content
← All posts

TIL: Postgres partial indexes saved our dashboard

1 min read#postgres

Most invoices are paid, but the dashboard only asks for unpaid ones. A partial index covers just those rows:

migrations/add_unpaid_index.sql
CREATE INDEX invoices_unpaid_idx ON invoices (due_date) WHERE paid_at IS NULL;