Repository navigation
Do not execute the PrimaryKeyExpand step if skip index is already part of primary key - #93899
Merged
rschu1ze merged 4 commits intoJan 20, 2026
Merged
Conversation
shankar-iyer
marked this pull request as draft
January 12, 2026 10:29
Contributor
|
Workflow [PR], commit [919f2ce] Summary: ❌
|
Member
Author
|
Clean CI run at |
shankar-iyer
marked this pull request as ready for review
January 13, 2026 04:46
Merged
via the queue into
ClickHouse:master
with commit Jan 20, 2026
210ebef
127 of 128 checks passed
robot-clickhouse
added a commit
that referenced
this pull request
Jan 26, 2026
… skip index is already part of primary key
shankar-iyer
added a commit
that referenced
this pull request
Jan 26, 2026
Backport #93899 to 25.12: Do not execute the PrimaryKeyExpand step if skip index is already part of primary key
Member
|
Please beware that this is introducing a bug: I'll send a possible fix, but please keep in in mind for any release where this change, or anything related/superseeded by it, was backported |
Member
Author
|
Thanks @Algunenano ! |
1 task
alexey-milovidov
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Oct 19, 2026
…nal mark The skip indexes of the existing table are on primary key columns, so the `findPKRangesForFinalAfterSkipIndex` pass is skipped there since ClickHouse#93899 and the comment-only change of this test made the bugfix validation job red. Add a table with a skip index on a column outside of the primary key: the pass now runs, meets the part without the final mark and must keep the ranges selected by the primary key. On master it reads the whole part and fails with `TOO_MANY_ROWS` under `max_rows_to_read = 1000`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126118&sha=1386de4359b9686d30258cb768202ddaef6284ac&name_0=PR&name_1=Bugfix%20validation%20(functional%20tests%2C%20amd64) ClickHouse#126118 Co-Authored-By: Claude Opus 5.5 <[email protected]>
UberDever
pushed a commit
to UberDever/ClickHouse
that referenced
this pull request
Oct 19, 2026
…mary key column `buildIndexes` turns `use_skip_indexes_if_final_exact_mode` off when every column of every useful skip index is in the primary key (ClickHouse#93899): rows of one FINAL group have equal key values, so such an index cannot drop the winner of a group while keeping an older version. For floats that premise is false. The FINAL merge treats -0.0 and 0.0, and all NaN payloads, as one key, while a skip index stores the actual values. With rows (1, 0.0, 1) and (1, -0.0, 2) in two parts and `INDEX ix_f f TYPE set(0)` on key column `f`, `FINAL WHERE toString(f) = '0'` drops the granule with the winner and returns the superseded row; SummingMergeTree returns a partial sum. Build the set of primary key columns with `sortingKeyNamesSafeBeforeFinal`, which excludes float-containing columns for the same reason in deferred row policies (ClickHouse#121782). A skip index on a float key column now keeps the exact-mode recovery pass on; for such keys it reads the whole surviving parts, as it already does for an index on a non-key column of these tables. Indexes on non-float key columns keep the shortcut. Closes ClickHouse#122346 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #89395
Re-reverts #88368 with extra fortification
Details
Assume a
ReplacingMergeTreetable withORDER BY (id1, id2)and two skip indexes:id2_idxonid2(which is part of the primary key) andv_idxonv(which is not part of primary key).With rows (
1,1,'blue')and(1,1,'red')in different parts, the second row is a modification of the first row. Using skip indexv_idxin aFINALquery withWHERE v = 'blue'requires thePrimaryKeyExpandstep (use_skip_indexes_if_final_exact_mode=1) to return correct results.With rows
(1,1,'blue')and (1,2,'blue')in different parts, the second row is a different row. Skip indexid2_idxcan be safely used without needing the primary key intersection step for aFINALquery with e.gWHERE id2 = 2Changelog category (leave one):
Changelog entry (a [user-readable short description]
If a skip index used in a
FINALquery 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 #85897Version info
26.1.1.71125.12.5.19