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:
CREATE INDEX invoices_unpaid_idx ON invoices (due_date) WHERE paid_at IS NULL;