Index fields that are commonly used together.
Section: Create index patterns
Create a composite index
sql
sql
CREATE INDEX idx_orders_status_created_at ON orders (status, created_at DESC);Explanation
Useful for queries that filter by `status` and then sort or range on `created_at`.
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 Create index patterns
PostgreSQL covering index with INCLUDE
Store extra columns for index-only scans.
Design for equality then range
Put equality columns first in many B-tree cases.