Index multiple columns in left-to-right order.
Section: indexes
Create a composite index
sql
sql
CREATE INDEX idx_orders_user_status_created ON orders (user_id, status, created_at);Explanation
Composite indexes can accelerate queries that filter by the leading columns.
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 indexes