Bird
0
0

You wrote this query on a partitioned table orders partitioned by order_date:

medium📝 Debug Q14 of 15
PostgreSQL - Table Partitioning
You wrote this query on a partitioned table orders partitioned by order_date:
SELECT * FROM orders WHERE EXTRACT(YEAR FROM order_date) = 2023;

Why might partition pruning NOT occur?
APartition pruning only works with numeric columns
BUsing a function on the partition key disables pruning
CThe query syntax is invalid
DPartition pruning requires an index on order_date
Step-by-Step Solution
Solution:
  1. Step 1: Identify pruning limitation

    Partition pruning requires direct use of the partition key in filters without wrapping functions.
  2. Step 2: Analyze the query

    The query uses EXTRACT(YEAR FROM order_date), a function on the partition key, preventing pruning.
  3. Final Answer:

    Using a function on the partition key disables pruning -> Option B
  4. Quick Check:

    Functions on partition keys disable pruning [OK]
Quick Trick: Avoid functions on partition keys for pruning [OK]
Common Mistakes:
  • Thinking pruning needs indexes
  • Believing pruning works with any filter
  • Assuming query syntax error causes pruning failure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes