Bird
0
0

Given the partitioned table orders partitioned by range on order_date, what will the query SELECT * FROM orders WHERE order_date < '2023-01-01'; do?

medium📝 query result Q4 of 15
PostgreSQL - Table Partitioning
Given the partitioned table orders partitioned by range on order_date, what will the query SELECT * FROM orders WHERE order_date < '2023-01-01'; do?
AReturn an error because partition pruning is not supported
BScan all partitions regardless of date
CScan only the latest partition
DScan only partitions with order_date before 2023-01-01
Step-by-Step Solution
Solution:
  1. Step 1: Understand partition pruning

    PostgreSQL scans only relevant partitions based on query conditions.
  2. Step 2: Apply to given query

    Query filters order_date before 2023-01-01, so only partitions with those dates are scanned.
  3. Final Answer:

    Scan only partitions with order_date before 2023-01-01 -> Option D
  4. Quick Check:

    Partition pruning = Scan only partitions with order_date before 2023-01-01 [OK]
Quick Trick: Partition pruning scans only needed partitions [OK]
Common Mistakes:
  • Assuming all partitions are scanned
  • Thinking partition pruning causes errors
  • Believing only latest partition is scanned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes