Use bounds to prove a region cannot match
Apply conservative min/max pruning with correct null and ordering semantics while distinguishing overlap from evidence that matching rows exist.
On this page
The question for today
What you’ll understand
- Derive a safe skip condition for a half-open range predicate.
- Handle absent statistics and null counts without inventing evidence.
- Explain why low row selectivity need not imply effective region pruning.
A zone map summarizes a region cheaply so a reader can avoid opening data that cannot satisfy a predicate. Its job is to prove absence, not to replace evaluating the query on surviving rows. This distinction is essential: a conservative summary may retain unnecessary regions, but an unsound summary can silently remove correct answers. Treat pruning as a small logical proof whose assumptions include type ordering, null behavior, and trustworthy metadata.
A nonoverlapping bound justifies a skip
Suppose a region's nonnull finite values lie within inclusive bounds L and U under the same order used by the query. For the predicate x at least a and strictly below b, no value can match when U is below a or L is at least b. If the intervals overlap, the region merely remains a candidate: bounds alone cannot establish which intermediate values occur. This asymmetry makes a false positive acceptable as extra work, while a false negative is a query correctness failure.
Parquet can supply column-chunk statistics and an optional page index for finer navigation. Page-index bounds can be conservative rather than actual values present, allowing truncated summaries of long strings. Readers must interpret the specified column order and metadata contract. Bytewise string order, signed numbers, decimal interpretation, NaNs, and application collations cannot be casually interchanged. If a cast or user-defined predicate does not have a justified relationship to the stored bounds, retain the region or use another sound rule instead of guessing that a familiar-looking range test still applies.
Nulls require their own evidence
SQL comparison predicates do not evaluate to true for a null input, so an entirely null region cannot contribute to this ordinary range filter. But an IS NULL query asks a different question and needs validity information. Parquet statistics fields are optional; an absent null count does not mean zero nulls. A missing or unusable min/max also does not mean an empty region. Distinguish known all-null, known no-null, and unknown states explicitly in the pruning logic, then test each with actual query semantics.
Composing predicates needs the same care. A region can be rejected for an AND when one conjunct is impossible; rejecting an OR generally requires proving every alternative impossible. A predicate that involves several columns may leave many false positives because independent per-column bounds do not preserve their correlations. For instance, a region can contain low x only with high y and high x only with low y, while separate ranges suggest a combination that never occurs. Retain candidates and evaluate rows rather than pretending a zone map is a multidimensional exact index.
Layout determines whether summaries are informative
A sorted or clustered range key often produces narrower region bounds than uniformly mixed values, improving the opportunity to reject groups. Row selectivity and region selectivity are different: one percent of matching rows spread across every page can require reading almost every page. Smaller regions can sharpen summaries but add metadata and requests. Measure regions considered, regions rejected, ranges fetched, and rows evaluated. Compare query answers with pruning disabled so an optimization cannot hide a mistaken type or null interpretation behind a faster runtime.
For a probability illustration, Reset the lab, set both p=0.2 and n=20, predict four relevant regions on average, then Play or Step. Interpret p as a hypothetical independent probability that a whole region is relevant, not as row selectivity. Playback highlights exact binomial bars rather than sampling files. Reset and re-enter both controls before another case because edits retain elapsed time. The model computes neither min/max summaries nor actual pruning decisions; those require the logical conditions and metadata checks above.
Work it through
Reject regions without inventing matches
Three regions each hold 1,000 nonnull integers. Their valid inclusive bounds are [0,9], [10,19], and [20,29]. Apply x≥12 AND x<18 using only the bounds.
The first region has upper bound nine, below twelve, so it cannot match and can be skipped.
The third region has lower bound twenty, at least eighteen, so it also cannot match. The middle region overlaps the query range and must remain a candidate.
Pruning avoids evaluating 2,000 of the 3,000 rows at this region level, about 66.7 percent. Bounds do not tell us how many of the middle region's rows equal any integer twelve through seventeen, so its data still needs evaluation.
Two regions are safely rejected. The remaining region is possible work, not proof that a matching row exists or that six-tenths of its rows qualify.
The living notebook
Explore the model
Interactive lab · probability
Region selectivity differs from row selectivity
Reset, set both p=0.2 and n=20, predict mean four relevant regions, then Play or Step. p is a hypothetical independent region-relevance probability, not row selectivity. Reset and re-enter both controls before a comparison. The exact binomial bars do not inspect files, compute zone maps, or perform predicate pruning.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA low fraction of matching rows can still leave most physical regions as candidates, depending on layout and summaries.
Pause & reason
Check your understanding
Your turn
Try it yourself
A region has valid inclusive finite numeric bounds [40,60]. Decide whether it can be skipped for x≥60 AND x<70, and separately for x≥61 AND x<70. Explain the boundary difference.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The maximum bound is inclusive, while the query's upper endpoint is exclusive.
Compare with the solution
It cannot be skipped using these bounds for the first predicate because a value of sixty may occur and would match. For the second, the upper bound sixty is below the lower query bound sixty-one, so no nonnull value can match and skipping is safe under the stated order and statistics assumptions.
Keep the idea
Take it with you
- Pruning is a proof of impossibility; overlapping bounds only retain a candidate.
- Absent statistics, nulls, logical ordering, and predicate composition require explicit rules.
- Clustering and physical granularity determine region selectivity independently of row selectivity.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.