Repository navigation
Enable apply_string_filters_during_scan by default - #124507
Conversation
The optimization was added in #115848. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [21e004a] Summary: ✅
AI ReviewSummaryThis PR enables Findings
Final Verdict
|
…ad without the string filter `PageDecoderInfo::makeDecoder` does not pass the `StringValueFilter` to `DeltaByteArrayDecoder`, so the setting is a no-op for such pages until #124503 is merged. Narrow the advertised support accordingly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erformance regressions The performance comparison of this PR showed confirmed slowdowns on both architectures when `apply_string_filters_during_scan` is enabled: `text_index_like` (+40..60%), `tpch` #9 and #18 (+20..25%). https://s3.amazonaws.com/clickhouse-test-reports/PRs/124507/39c02e6cc3685359d573bfcec24d5f6e1c9c05fd/pr/performance_comparison_arm_release_master_head_6_6/report.html Two causes: - The filter was evaluated on the first 65536 values before deciding whether it pays off. For small queries (e.g. a text index leaves ~100k rows that all match) this covers almost the whole query, so the non-selective filter only added the per-value check. The window is now 8192 values. - For short values (e.g. `l_returnflag = 'R'`, `l_shipinstruct = '...'`), the filter is selective, but skipping the copy of a few bytes does not compensate for checking every value. The filter is now also disabled when it skips less than 16 bytes per checked value on average. Measured locally (CPU cycles, setting off -> on): the `text_index_like` query went from +19% to +5%, equality on short `String` columns went from +26..37% to +0.5%. The benefit for selective conditions on long values is kept. The non-matching values in the dictionary pruning case of `05055_string_filters_during_scan_parquet` are made longer, so that the test still checks what it intends to (dictionary materialization must not feed the selectivity statistics) instead of hitting the new short value threshold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124507&sha=39c02e6cc3685359d573bfcec24d5f6e1c9c05fd&name_0=PR&name_1=Integration%20tests%20%28amd_llvm_coverage%2C%204%2F8%29 ( |
|
🕵 The performance comparison showed confirmed slowdowns ( |
|
Acknowledged. I'm investigating |
|
📊 Cloud Performance Report 🟢 AI verdict: One query was flagged: clickbench Q20 ( clickbench🟢 1 improved Flagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
|
The fix is in #124691 (test-only). The secret in the log comes from the test's own #124691 makes the server log checks skip every log entry of the probe queries (matched by query id, including continuation lines), and the probes now pin the setting, so the module covers this path on master too. |
…oded `Parquet` rows The rule that disables `StringValueFilter` when it skips less than 16 bytes per checked value assumes that every value was checked against the filter. For dictionary-encoded `Parquet` pages, every distinct dictionary entry is checked once in `Dictionary::buildStringValueFilterMask`, and the rows only look up the result in a mask, so the filter is cheap there even for short low-cardinality values (e.g. `l_returnflag`). Add `StringValueFilter::updateStatsForMaskedValues`, used by `Dictionary::appendIndexes` and `Dictionary::appendRepeated`: such rows participate in the selectivity rule, but not in the minimum average size of skipped values, which is now evaluated only over individually checked values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rging master Master now applies the string filter to `DELTA_BYTE_ARRAY` Parquet pages (#124503), so the setting description no longer says that such pages are read without it. The dictionary pruning case of `05055_string_filters_during_scan_parquet` is restored to the version from master: dictionary-encoded rows no longer participate in the short value cutoff, so the longer non-matching values are not needed. The new test is renumbered to `05339`, because master added another `05338` test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failures: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124507&sha=c23830da59a1b40c99e7f571ab0713e737009542&name_0=PR and provide a fix in a separate PR. If the fix is already in progress, link it here.
Also merged master and addressed the review: rows of dictionary-encoded |
|
I checked all three on c23830d:
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units310 translation units recompiled, 3382 s compile time in total, 310 of them have a recent master baseline. |
…MergeTree` values In `deserializeBinaryFilteredWithKnownSizes`, a substring condition is checked by a single scan of the buffer of concatenated values (`findBulkScanMatches`), and only the candidate rows are checked with `matchOtherConditions`. Such values are not checked one by one, so the minimum average size of skipped values must not disable the filter for them: selective `LIKE` / `position` on short strings is exactly the case the bulk scan is for. Report them with `updateStatsWithoutPerValueChecks` (renamed from `updateStatsForMaskedValues`, which is also used by the dictionary-encoded `Parquet` pages), so they only participate in the selectivity rule. Co-Authored-By: Claude Opus 5.5 <[email protected]>
check_logs() grepped the whole server log for each checked string and skipped only lines containing the probe's SQL prefix. The probe itself logs the string, and with apply_string_filters_during_scan = 1 the LIKE conjunct alone is moved to PREWHERE: the PREWHERE trace lines and the multi-line "Original PREWHERE DAG:" dump print it without the prefix (continuation lines carry no query id at all). The Azurite account key is shared by several tests, so the connection-string probe of test_table_functions_object_storage_cluster failed the later test_backup_table_azure_named_collection and test_iceberg_cluster_function (seen on ClickHouse#124507). Run the probes with a fixed query id prefix and drop every log entry of such a query, header and continuation lines, before grepping. All other log lines are still checked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r conditions In a bulk scan of a buffer of concatenated `String` values, the candidates found by the scan are checked one by one against the other conditions of the filter (e.g. for `LIKE '%a%b%'`). Such checks now participate in the minimum average size of skipped values, so the filter disables itself when there are many short candidates. The bytes skipped by the scan itself are attributed to these checks, so the filter stays enabled when the scan rejects most of the values before the per-value checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
LGTM one more time.
Since #124131, the only input of the last PREWHERE step on a dictionary-encoded Parquet `String` column is read as dictionary indexes when no earlier step reads it (`decode_dictionary_as_replicated`), and its dictionary values come from `Reader::getDictionaryValues` with `use_string_value_filter = false`. So a single-column `PREWHERE s LIKE '%R%'` no longer passes through `StringValueFilter` and `StringValueFilterValuesReplaced` stays 0, which made the last line of 05339 print 0 on every master run since d64fd50. #124131 adapted 05055 for the same reason (32e261a), but 05339 was added by #124507 after #124131's last CI run, so it was never adapted. Add the same always-true conjunct `AND id < 100000` to the three PREWHERE queries: the conjunct order is kept, so `s` is read by the first of two steps and goes through the masked `Dictionary::appendIndexes` path the test checks. It goes on the two `apply_string_filters_during_scan = 0/1` comparison queries too, because with the single-column shape both arms read indexes and the comparison compared nothing. The reference does not change. Validated on a debug build of d64fd50: the old test fails 6/6, the new one passes 50/50 randomized (66667 replaced, 0 rows read as indexes). Reporting the mask lookups through `updateStats` instead of `updateStatsWithoutPerValueChecks` makes the new test fail 8/8 (5712-6384 replaced). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The ClickBench nightly shows single-file Parquet Q21 ( Hot time in seconds (best of tries 2–3, range over runs), from the nightly results:
Q22 (same Toggling the setting with the same binary does not reproduce it on 4-vCPU hosts. With official master builds (warm page cache, |
The merge-queue flaky check reran only the PR's own new/changed tests. That catches a `master` change breaking the PR's tests, but not the reverse: the PR breaking a test that landed on `master` after the PR's last CI run. This is how ClickHouse#124131 broke `05339_string_filters_during_scan_parquet_short_dictionary_values` from ClickHouse#124507 and was reverted by ClickHouse#126396. The `Config Workflow` job of the merge queue, which has the commit history, now finds the tests changed on the first-parent history of the queue base after the PR head commit time (or after the merge base, if the PR merged `master` since), and stores them for the flaky check. When there are more than 30, the ones whose names share more words with the names of the files changed by the PR come first. For the merge-queue commit of ClickHouse#124131 (`d64fd503b42e`), the range has 819 tests, and 05339 is selected second. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Enable the pushdown of substring search conditions on
Stringcolumns fromPREWHEREinto the column scan, added in #115848. Until now it was off by default. The setting has been randomized inclickhouse-testsince that PR. The tests that depend on it already pin its value.The performance comparison showed confirmed regressions with the setting enabled (
text_index_like,tpch#9 and #18). They are fixed by making the adaptive disabling ofStringValueFilterstricter: the selectivity is evaluated after 8192 values instead of 65536, and the filter is also disabled when it skips less than 16 bytes per checked value on average (e.g. equality on shortStringcolumns, likel_returnflag = 'R'), because then the check of every value costs more than the skipped copy. For rows that are not checked one by one, the cost is the number of checks actually done. For dictionary-encodedParquetpages that is one check per distinct dictionary entry, credited with the bytes the mask is expected to skip across the rows of the column chunk. For a bulk scan ofMergeTreevalues, it is the candidates re-checked against the other conditions of the filter. TheParquetdecoders also update the statistics every 8192 values instead of once per page. Before, the pages of all row groups were decoded in parallel and each was checked completely before the filter could disable itself. This fixes theclickbench_parquet_short#6 regression (URL LIKE '%google%'on short, almost unique values).Related: #115848
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enabled the setting
apply_string_filters_during_scanby default. Substring search conditions onStringcolumns (LIKE,position,startsWith,endsWith) fromPREWHEREare pushed down into the column scan, and non-matching values are read as empty strings without copying their data. This makes such queries faster and lowers their memory usage when reading fromMergeTreetables and fromParquetpages whose string values use thePLAIN,DELTA_LENGTH_BYTE_ARRAY,DELTA_BYTE_ARRAY, or dictionary encodings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/124507]
Version info
26.10.1.2311-master(included in26.10and later)