Skip to content

fix(query): improve selectivity estimation for boolean expressions - #20237

Open
forsaken628 wants to merge 2 commits into
databendlabs:mainfrom
forsaken628:bool-stat
Open

fix(query): improve selectivity estimation for boolean expressions#20237
forsaken628 wants to merge 2 commits into
databendlabs:mainfrom
forsaken628:bool-stat

Conversation

@forsaken628

@forsaken628 forsaken628 commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • estimate non-nullable Boolean predicates without column statistics using an even true/false distribution
  • handle Boolean comparisons according to their possible outcomes, while keeping nullable Boolean comparisons unknown when null statistics are unavailable
  • preserve concrete numeric estimates in mixed AND predicates instead of letting Unknown or LowerBound fallbacks override them

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

AI assistance

  • AI usage: An AI coding agent assisted with implementation.
  • Responsible human: @forsaken628
  • The responsible human has read every line of this diff and can explain each change

This change is Reviewable

@forsaken628
forsaken628 marked this pull request as ready for review July 31, 2026 12:20
@github-actions github-actions Bot added the pr-bugfix this PR patches a bug in codebase label Jul 31, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad995c4e6c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/query/sql/src/planner/optimizer/ir/stats/selectivity.rs
Comment thread src/query/sql/src/planner/optimizer/ir/stats/selectivity.rs
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

🤖 CI Job Analysis (Retry 1)

Workflow: 30643497863

📊 Summary

  • Total Jobs: 90
  • Failed Jobs: 2
  • Retryable: 0
  • Code Issues: 2

NO RETRY NEEDED

All failures appear to be code/test issues requiring manual fixes.

🔍 Job Details

  • linux / sqllogic / standalone (standalone, 2c, http): Not retryable (Code/Test)
  • linux / sqllogic / standalone (standalone, 2c, hybrid): Not retryable (Code/Test)

🤖 About

Automated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix this PR patches a bug in codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant