Skip to content

Improve selectivity estimation for CASE and SubPlan IS NULL patterns#4850

Open
RuchaSK1 wants to merge 1 commit into
babelfish-for-postgresql:BABEL_6_X_DEVfrom
amazon-aurora:jira-babel-6458-part3
Open

Improve selectivity estimation for CASE and SubPlan IS NULL patterns#4850
RuchaSK1 wants to merge 1 commit into
babelfish-for-postgresql:BABEL_6_X_DEVfrom
amazon-aurora:jira-babel-6458-part3

Conversation

@RuchaSK1

@RuchaSK1 RuchaSK1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Implementing planner hooks that provide accurate selectivity for:

  • OpExpr: Decomposes CASE expressions compared to constants using
    conditional probability across branches
  • NullTest: Uses SubPlan estimated row count to determine IS NULL
    probability instead of the default 99.5%

These hooks fix row count misestimates in SSMS Object Explorer queries that use the is_ms_shipped CASE filter pattern, improving plan choices from Nested Loop to Hash Join.

Issues Resolved

[List any issues this PR will resolve]

Test Scenarios Covered

  • Use case based -

  • Boundary conditions -

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Rucha Kulkarni <ruchask@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant