Partition Pruning from Query Predicates
Prove which partitions cannot contain matching rows and see why a transformed predicate can be harder for an optimizer to use.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Match the predicate to the partition bounds
A date-partitioned table can put rows into half-open monthly intervals. If a query requests the range from March 5 to March 10, only a partition whose bounds intersect that range can contribute. Pruning skips others before scanning them. Bound conventions for equality, default partitions and missing values need to match the actual schema.
Only remove work when exclusion is justified
A predicate on an arbitrary function of the date might be equivalent to a bounded range, but the optimizer needs a rule or proof to see it. Parameters may become known only during execution, motivating runtime pruning. Partition elimination is separate from choosing an index inside the selected partitions. Composite index ranges show a related interval reasoning at a finer level. Plan inspection reveals how much work was actually excluded.[1][2]