SQL Window Functions: Performance, EXPLAIN, and Dialect Notes/Create a supporting index for partition/order keys
Help the database read rows in the right order.
Section: Performance patterns
Create a supporting index for partition/order keys
sql
sql
CREATE INDEX idx_orders_customer_date
ON orders (customer_id, order_date);Explanation
An index that aligns with `PARTITION BY` and `ORDER BY` can reduce expensive sorts or improve access patterns.
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 Performance patterns
Materialize an expensive intermediate result
Break a huge query into smaller stages.
QUALIFY shortcut in some warehouses
Filter window results without wrapping a subquery.