Bird
0
0

How does PostgreSQL's default CTE materialization behavior affect query optimization in versions before 12 compared to version 12 and later?

hard📝 Application Q9 of 15
PostgreSQL - Common Table Expressions
How does PostgreSQL's default CTE materialization behavior affect query optimization in versions before 12 compared to version 12 and later?
ABefore v12, CTEs are inlined by default; from v12, always materialized
BBefore v12, CTEs are always materialized; from v12, they can be inlined by default
CCTE materialization behavior is unchanged across versions
DCTEs are deprecated in v12 and later
Step-by-Step Solution
Solution:
  1. Step 1: Recall PostgreSQL version changes

    Before version 12, CTEs were always materialized, preventing some optimizations.
  2. Step 2: Understand v12+ behavior

    From version 12, PostgreSQL can inline CTEs by default unless forced MATERIALIZED.
  3. Final Answer:

    Before v12, CTEs are always materialized; from v12, they can be inlined by default -> Option B
  4. Quick Check:

    PostgreSQL v12+ allows CTE inlining by default [OK]
Quick Trick: PostgreSQL v12+ inlines CTEs by default [OK]
Common Mistakes:
  • Thinking behavior is unchanged
  • Assuming CTEs deprecated in v12
  • Confusing default materialization direction

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes