EXPLAIN ANALYZE
SELECT customer_id,
order_date,
amount,
SUM(amount) OVER (
PARTITION BY customer_id
ORDER BY order_date
) AS running_total
FROM orders;Look for large sorts, temp files, repartition steps, or repeated scans depending on the database.