Skip to content

Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate - #98776

Merged
azat merged 1 commit into
ClickHouse:masterfrom
azat:fix-set-index-with-or
Mar 5, 2026
Merged

azat merged 1 commit into
ClickHouse:masterfrom
azat:fix-set-index-with-or

Conversation

@azat

@azat azat commented Mar 4, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate

Fixes: #87781


Note

Medium Risk
Changes set skipping-index applicability logic for OR predicates, which can alter query plans and index selection. Risk is limited to optimization behavior but could affect performance or force_data_skipping_indices expectations.

Overview
Fixes MergeTreeIndexConditionSet::checkDAGUseless to treat constant-false children in or(...) as identity elements, preventing or(non_indexed_predicate, 0) from incorrectly making the set index look usable.

Adds a stateless regression test covering or(a = 5, 0) (index must not be used) and or(b = 5, 0) (index must still be used) when forcing idx_b.

Written by Cursor Bugbot for commit e854004. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.3.1.425
  • Backported to: 26.2.4.24, 26.1.5.11, 25.12.9.18

@azat
azat requested a review from shankar-iyer March 4, 2026 18:01
@clickhouse-gh

clickhouse-gh Bot commented Mar 4, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e854004]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) failure
01655_window_functions_bug FAIL cidb
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-41a5) FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 4, 2026
@azat
azat marked this pull request as draft March 4, 2026 19:52
@azat

This comment was marked as outdated.

@azat
azat force-pushed the fix-set-index-with-or branch from 15bd4ee to 0cb13a0 Compare March 4, 2026 23:01
@azat azat changed the title Fix set skip index with OR condition (was always used even if it is useless) Fix set skip index with OR condition Mar 4, 2026
@azat
azat force-pushed the fix-set-index-with-or branch from 0cb13a0 to e98e653 Compare March 4, 2026 23:04
@azat azat changed the title Fix set skip index with OR condition Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate Mar 4, 2026
@azat
azat marked this pull request as ready for review March 4, 2026 23:04
@shankar-iyer

Copy link
Copy Markdown
Member

Test failures in Stateless tests (arm_asan, azure, parallel) (pull_request) are due to Azure errors, should go away in rerun.

…, 0)) predicate

The problem was that MergeTreeIndexConditionSet::checkDAGUseless() has
noe more check for bools (getBool(0) == 0)), which is not correct for
OR (only for AND).
@azat
azat force-pushed the fix-set-index-with-or branch from e98e653 to e854004 Compare March 5, 2026 07:31
@azat
azat added this pull request to the merge queue Mar 5, 2026
Merged via the queue into ClickHouse:master with commit 06a133e Mar 5, 2026
145 of 146 checks passed
@azat
azat deleted the fix-set-index-with-or branch March 5, 2026 12:03
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo labels Mar 5, 2026
robot-clickhouse added a commit that referenced this pull request Mar 5, 2026
…h OR with false (i.e. or(x, 0)) predicate
robot-clickhouse added a commit that referenced this pull request Mar 5, 2026
… OR with false (i.e. or(x, 0)) predicate
robot-clickhouse added a commit that referenced this pull request Mar 5, 2026
… OR with false (i.e. or(x, 0)) predicate
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Mar 5, 2026
clickhouse-gh Bot added a commit that referenced this pull request Mar 5, 2026
Backport #98776 to 26.1: Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate
clickhouse-gh Bot added a commit that referenced this pull request Mar 5, 2026
Backport #98776 to 26.2: Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate
azat added a commit that referenced this pull request Mar 5, 2026
Backport #98776 to 25.12: Fix detecting set skip index usefulness with OR with false (i.e. or(x, 0)) predicate
alexey-milovidov added a commit that referenced this pull request Apr 24, 2026
Per reviewer feedback, `functional_tests_jobs_azure` should only run
in master and the private repo, not in every pull request. Running
them per-PR was expensive and exposed the feedback loop to Microsoft
Azure outages, which we already hit on PR #98776.

The jobs remain in `ci/workflows/master.py` so the master branch
still exercises the Azure storage integration.

Addresses review feedback on PR #102354.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v25.12-must-backport v26.2-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants