SQL Window Functions: Performance, EXPLAIN, and Dialect Notes/Materialize an expensive intermediate result
Break a huge query into smaller stages.
Section: Performance patterns
Materialize an expensive intermediate result
sql
sql
CREATE TEMP TABLE recent_orders AS
SELECT *
FROM orders
WHERE order_date >= CURRENT_DATE - INTERVAL '1 year';Explanation
Materialization can help when a complex join or filter should not be recomputed before the window stage.
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.
QUALIFY shortcut in some warehouses
Filter window results without wrapping a subquery.