Bird
0
0

Given a table orders partitioned by range on order_date, what will the query below return?

medium📝 query result Q13 of 15
PostgreSQL - Table Partitioning
Given a table orders partitioned by range on order_date, what will the query below return?
SELECT count(*) FROM orders WHERE order_date < '2023-01-01';
ACount of all orders before 2023-01-01 from all relevant partitions
BCount of orders only from the first partition
CSyntax error due to partitioning
DCount of all orders ignoring the date filter
Step-by-Step Solution
Solution:
  1. Step 1: Understand partition pruning in PostgreSQL

    PostgreSQL automatically checks only partitions that can contain rows matching the WHERE condition.
  2. Step 2: Analyze the query effect

    The query counts rows with order_date before 2023-01-01 across all relevant partitions.
  3. Final Answer:

    Count of all orders before 2023-01-01 from all relevant partitions -> Option A
  4. Quick Check:

    Partition pruning returns matching rows only [OK]
Quick Trick: Partition pruning counts only matching partitions [OK]
Common Mistakes:
  • Thinking query counts only first partition
  • Assuming syntax error due to partitioning
  • Ignoring WHERE clause and counting all rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes