Problem Statement
Which statement compares a CTE and a temporary table accurately?
Explanation
Temp tables live for the session or transaction and can be indexed and referenced many times. They are good for reuse and complex pipelines.
CTEs are single statement helpers. Many engines inline them; some may materialize. Pick based on reuse and performance needs.
Code Solution
SolutionRead Only
CREATE TEMP TABLE t AS SELECT * FROM big WHERE flag=1; CREATE INDEX ON t(id); SELECT * FROM t JOIN dim USING(id);
Practice Sets
This question appears in the following practice sets:
