CS FundamentalsModerateTCS NQT · Infosys pattern
A table is partitioned by RANGE on a date column (e.g. one partition per year). A query filters `WHERE sale_date BETWEEN '2023-01-01' AND '2023-12-31'`. What optimization does the query planner typically apply, called 'partition pruning'?
- A. It converts the range partitioning into hash partitioning at query time
- B. It scans every partition anyway, since partitioning doesn't help filtering
- C. It identifies, from the query's date range, which partition(s) COULD possibly contain matching rows and skips scanning the other partitions entirely
- D. It merges all partitions back into a single table before executing the query
Correct answer: C. It identifies, from the query's date range, which partition(s) COULD possibly contain matching rows and skips scanning the other partitions entirely
Partition pruning uses the partitioning scheme's boundaries (known at plan time) to determine that only the 2023 partition can possibly satisfy a 2023-only date filter, so the other partitions (other years) are never even opened or scanned — a major I/O saving for well-partitioned, time-series-style tables.
More DBMS and SQL questions
- A relation R(A, B, C, D, E) has FDs AB → CDE and E → B. What are the candidate key(s) of R?
- Using the same R(A, B, C, D, E) with AB → CDE and E → B, how many superkeys does R have in total?
- R(A, B, C) has NO nontrivial functional dependencies at all (every attribute is independent of every other). What is R's only candidate…
- A relation R(A, B, C, D) has FDs A → BC and D → A (so D is also, indirectly, able to derive B and C). What are the candidate keys of R?
- A trigger-based implementation of a materialized view manually re-runs the entire defining query and replaces all the materialized rows…
- R(City, Street, Zip) has FDs City,Street → Zip and Zip → City, with candidate keys {City,Street} and {Street,Zip}. Decomposing into…