Repository navigation
Share the values of a sparse column in ColumnSparse::index when the rows are its own non-default rows - #129705
Conversation
A condition such as `s != ''` on a sparse column is computed on its values only and returned as Sparse(UInt8) with the column's own offsets, so FilterTransform calls `index` with exactly the non-default rows of that column. Return a column that shares `values` instead of copying each value. Analysis and patch by snelheidai, ClickHouse#129686. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review of the diff (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261106-103100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261106-100400 |
|
Workflow [PR], commit [f637c66] Summary: ❌
AI ReviewSummaryThe PR avoids copying the payload in Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
CI finish ledger - 3c8852aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261106-143004 |
|
Fixing PR for the |
0e42176
Related: #129686
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Faster
WHEREfiltering of a sparse column by a condition that keeps exactly its non-default rows (for exampleWHERE s != ''on a sparseStringcolumn): the column's values are shared instead of copied.Description
A condition such as
s != ''on a sparse column is computed on its values only and returned asSparse(UInt8)with the column's own offsets, soFilterTransformcallsindexwith exactly the column's non-default rows.ColumnSparse::indexImplthen copied every value with a virtualinsertFrom, although the result is the same values. This happens when the condition stays inWHERE(the filtered column is the only one read, as in ClickBench Q7) or withoptimize_move_to_prewhere = 0.Now, for
UInt64indexes, when there are as many indexes as non-default rows and they equal the offsets (memcmp),indexImplreturns a sparse column that sharesvalues.Measured locally, master
c9e18d01727evs this PR (Xeon 6975P-C, 16 pinned cores, ThinLTO, 95% CI):sparse_column_filterquerymax(str) ... WHERE str != '': 387 -> 317 ms (-18%) at 10% non-default.sparse_column_index_sortedWHERE a != 0 GROUP BY a: -13% / -15% in two runs.WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel: -15.8% [-18.6, -12.9] at 16 threads, -27.4% at 1 thread; Q7: -8.8% [-16.1, -0.9] and -15.6%.sparse_column*tests and none of the ClickBench controls (Q10, Q11, Q12) is significantly slower; results are identical.The issue's second part (copying consecutive values with one
insertRangeFrom) is not included: with ThinLTO it made the per-row insert lambda out-of-line andsparse_column_index_runs5-20% slower. Independent of #128852.Correctness: new
ColumnSparsegtests (own rows, a limit below the index count, other rows of the same count, mutating a shared result) fail without the change; a sparse-vs-full SQL differential and the*sparse*stateless tests match master.Analysis and patch by @ snelheidai in #129686.
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129705]
Version info
26.11.1.1971-master(included in26.11and later)