cockroachdb / cockroachdb/cockroach

opt: fix join selectivity from nulls removed

Open
#152,547 1 comment 0 reactions 0 assignees View on GitHub
A-sql-optimizer C-bug E-quick-win T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When modifying the estimated selectivity of join filters due to null-rejection, we currently use the not-null columns calculated for the join's output logical properties: https://github.com/cockroachdb/cockroach/blob/b39295a57bea99a0e4f60b12748e5b608cdf8885/pkg/sql/opt/memo/statistics_builder.go#L1467
This can cause over-estimates for semi-joins and anti-joins because they do not include columns from the right input in `Relational().NotNullCols`. Similarly, it can cause over-estimates for outer joins that may reject nulls from an input before null-extending it. In both cases we could use columns that were null-rejected by the join filters even though that null-rejection isn't reflected in the properties of the join.

Jira issue: CRDB-53911

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.