Skip to content

Better selectivity estimates for ORed predicates #75090

@msirek

Description

@msirek

Description
(#74303) Adds support for combining selectivities of ORed equijoin predicates with an industry-standard approach using the disjunction rule:

Given predicates A and B and probability function P:
P(A or B) = P(A) + P(B) - P(A and B)

This issue is opened to also apply the rule to single-table filter predicates on different columns for both Selects and Joins, e.g.,

col1 = 1 OR col2 = 1

Selectivities of predicates on the same column should be additive if the ranges are non-overlapping, e.g.,

col1 < 1 OR col1 > 15

Describe alternatives you've considered
Multicolumn stats could be used in the future to further improve estimates by getting a more accurate result for P(A and B).

Jira issue: CRDB-12458

Metadata

Metadata

Assignees

Labels

A-sql-optimizerSQL logical planning and optimizations.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions