Repository navigation
Use skip indexes through lossless conversions of the indexed column - #123239
Conversation
|
Workflow [PR], commit [78fd6ec] Summary: ❌
AI ReviewSummaryThis PR teaches index analysis to look through lossless wrappers around the indexed expression ( Missing context / blind spots
Final Verdict✅ No new inline findings. LLVM Coverage ReportMeasured on commit 78fd6ec.
Changed lines: Changed C/C++ lines covered: 65/65 (100.00%) · Uncovered code |
The `bloom_filter`, `tokenbf_v1` and `ngrambf_v1` indexes now look through `CAST`, `_CAST`, `toNullable` and `toLowCardinality` around the indexed expression when the conversion never changes the value and never throws (adding or dropping `LowCardinality`, adding `Nullable`, at any depth of `Array`), the same as the text index does since ClickHouse#120220. Such wrappers come from explicit casts, from `join_use_nulls` in pushed-down filters, and from casts of typed JSON paths, e.g. `has(['a'], json.Name::Nullable(String))`. `unwrapLosslessConversion` moves from the text index condition to `RPNBuilder` so that all index conditions share it. `toLowCardinality` now declares itself monotonic, like `toNullable`, so `KeyCondition` (primary key, `minmax`) accepts it in the monotonic chain. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
306cb6b to
ad5e5cf
Compare
Build profile diff (arm_release)Commit See the job log for details. |
…ss-conversion Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The AST form of `RPNBuilderTreeNode` was removed in master, so `getDAGNode` is never null. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
e5fdb03
Cherry pick #123239 to 26.7: Use skip indexes through lossless conversions of the indexed column
…ns of the indexed column
Cherry pick #123239 to 26.8: Use skip indexes through lossless conversions of the indexed column
…ns of the indexed column
Cherry pick #123239 to 26.9: Use skip indexes through lossless conversions of the indexed column
…ns of the indexed column
Backport #123239 to 26.8: Use skip indexes through lossless conversions of the indexed column
Backport #123239 to 26.9: Use skip indexes through lossless conversions of the indexed column
Backport #123239 to 26.7: Use skip indexes through lossless conversions of the indexed column
|
@CurtizJ — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
Since ClickHouse#123239, a query can use a text index on `s` through a lossless conversion of it, e.g. `CAST(s, 'String') LIKE ...` over a `LowCardinality(String)` column, or `toLowCardinality(s)` / `toNullable(s)`. The conversion stays in the fallback expression, so evaluating it once per read materializes a converted copy of the whole read instead of one granule. Fall back to the per-granule evaluation when a fallback expression applies a lossless conversion function directly to an input column. Measured on a debug build (1M rows, `max_threads = 1`, `max_block_size = 65536`): `CAST(lc, 'String') LIKE '%clickhouse%'` peak 36.84 MiB -> 33.10 MiB (same as the unwrapped query), while `message LIKE '%clickhouse%'` keeps the per-read path (FunctionExecute 80 vs 615 per granule). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #120220
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Skip indexes (
bloom_filter,tokenbf_v1,ngrambf_v1,minmax) and the primary key are now used when the indexed column is wrapped into a conversion that does not change its value, such astoLowCardinality,toNullableor aCASTtoNullableorLowCardinality.Workflow [PR]
Sync PR [sync-upstream/pr/123239]
Version info
26.10.1.1340-master(included in26.10and later)26.9.10.2,26.8.17.2,26.7.21.2