Index only the rows a hot query actually needs.
Section: PostgreSQL index types
Partial index
sql
sql
CREATE INDEX idx_orders_unshipped ON orders (created_at) WHERE shipped_at IS NULL;Explanation
Partial indexes reduce size and write cost when the workload focuses on a subset of rows.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing PostgreSQL index types