Bird
0
0

Why might PostgreSQL treat CTEs as optimization fences, and what impact does this have?

hard📝 Conceptual Q10 of 15
PostgreSQL - Common Table Expressions
Why might PostgreSQL treat CTEs as optimization fences, and what impact does this have?
ACTEs are executed independently, preventing planner optimizations across them
BCTEs always improve query speed by caching results
CCTEs automatically parallelize queries for better performance
DCTEs replace indexes to speed up lookups
Step-by-Step Solution
Solution:
  1. Step 1: Understand optimization fences concept

    PostgreSQL treats CTEs as separate query units, so it does not push filters or joins inside them.
  2. Step 2: Recognize impact on query planning

    This can prevent some optimizations, potentially making queries slower if not used carefully.
  3. Final Answer:

    CTEs are executed independently, preventing planner optimizations across them -> Option A
  4. Quick Check:

    CTEs act as optimization fences = B [OK]
Quick Trick: CTEs can block some query optimizations in PostgreSQL [OK]
Common Mistakes:
  • Assuming CTEs always speed queries
  • Believing CTEs parallelize automatically
  • Confusing CTEs with indexes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes