Start with the actual execution plan.
Section: Performance patterns
Inspect the plan with EXPLAIN
sql
sql
EXPLAIN ANALYZE
SELECT customer_id,
order_date,
amount,
SUM(amount) OVER (
PARTITION BY customer_id
ORDER BY order_date
) AS running_total
FROM orders;Explanation
Look for large sorts, temp files, repartition steps, or repeated scans depending on the database.
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
Create a supporting index for partition/order keys
Help the database read rows in the right order.
Materialize an expensive intermediate result
Break a huge query into smaller stages.
QUALIFY shortcut in some warehouses
Filter window results without wrapping a subquery.