Predicate Selectivity Under Correlation

Compare a product-of-marginals estimate with an exact joint count and trace its effect on plan choice.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Two common predicates need not filter independently
  2. A mistaken intermediate size can favor the wrong operator

Two common predicates need not filter independently

In a table of 1000 records, suppose 100 belong to category \(A\), and precisely those same 100 have flag \(B\). Each condition keeps one tenth of the table. Multiplying their selectivities predicts ten rows satisfying both, while the true count is 100. If the flagged group instead never overlaps category \(A\), the true conjunction count is zero with identical individual statistics.

A mistaken intermediate size can favor the wrong operator

An underestimated filter can make repeated index lookups look cheaper than processing a whole input, or reserve too little hash memory. Multicolumn statistics, constraints or sampled observations can help depending on dependencies. Histograms summarize marginal values. Cost-based query optimization connects these estimates to search over physical plans.[1][2]

References

  1. CMU 15-445/645, Introduction to Database Systems: Lectures ↩
  2. Patricia Selinger et al., Access Path Selection in a Relational Database Management System ↩