Skip to content

Do not perform PrimaryKeyExpand step if skip index is already part of primary key - #88368

Merged
shankar-iyer merged 8 commits into
ClickHouse:masterfrom
shankar-iyer:fix_issues_skip_index_final_exact_mode
Oct 30, 2025
Merged

shankar-iyer merged 8 commits into
ClickHouse:masterfrom
shankar-iyer:fix_issues_skip_index_final_exact_mode

Conversation

@shankar-iyer

@shankar-iyer shankar-iyer commented Oct 11, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

If a skip index used in a FINAL query is on a column that is part of the primary key, the additional step to check for primary key intersection in other parts is unnecessary and now not performed. Resolves #85897

Details

Assume following ReplacingMergeTree table with ORDER BY (id1, id2) and two skip indexes: id2_idx on id2 (which is part of the primary key) and v_idx on v (which is not).

With rows (1,1,'blue') and (1,1,'red') in different parts, the second row is a modification of the first. Using skip index v_idx in a FINAL query requires the PrimaryKeyExpand step (use_skip_indexes_if_final_exact_mode=True).

With rows (1,1,'blue') and (1,2,'blue') in different parts, the second row is a different row. Skip index id2_idx can be safely used without needing the primary key intersection step for FINAL.

@shankar-iyer
shankar-iyer marked this pull request as draft October 11, 2025 06:53
@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [061180f]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan, old analyzer, 5/6) failure
test_storage_nats/test_nats_core.py::test_nats_no_connection_at_startup_2 FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 11, 2025
@shankar-iyer
shankar-iyer marked this pull request as ready for review October 12, 2025 15:55
@shankar-iyer

Copy link
Copy Markdown
Member Author

@rschu1ze Please review!

@shankar-iyer

Copy link
Copy Markdown
Member Author

CI run is clean at daf47f5, but showed an unclear merge conflict in private repo. Refreshed to master.

@shankar-iyer

Copy link
Copy Markdown
Member Author

Only failure in test_storage_nats/test_nats_core.py::test_nats_no_connection_at_startup_2 is unrelated to PR.

robot-clickhouse added a commit that referenced this pull request Oct 30, 2025
@robot-clickhouse robot-clickhouse added pr-backports-created-cloud deprecated label, NOOP pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore labels Oct 30, 2025
rschu1ze added a commit that referenced this pull request Oct 31, 2025
Backport #88368 to 25.10: Do not perform PrimaryKeyExpand step if skip index is already part of primary key
rschu1ze added a commit that referenced this pull request Oct 31, 2025
Backport #88368 to 25.9: Do not perform PrimaryKeyExpand step if skip index is already part of primary key
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-backports-created-cloud deprecated label, NOOP pr-improvement Pull request with some product improvements pr-must-backport Pull request should be backported intentionally. Use this label with great care! 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use_skip_indexes_if_final_exact_mode incorrectly applied for skip index over ORDER BY column FINAL

4 participants