Skip to content

Resolve secondary index stream names without constructing index objects - #110050

Closed
azat wants to merge 1 commit into
ClickHouse:masterfrom
azat:index-stream-names-wo-index-object
Closed

azat wants to merge 1 commit into
ClickHouse:masterfrom
azat:index-stream-names-wo-index-object

Conversation

@azat

@azat azat commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Performance Improvement

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

Resolve secondary index stream names without constructing index objects

MergeTreeIndexFactory::get per part in clearCaches made DETACH slow: textIndexCreator builds ActionsDAG. Replace with MergeTreeIndexFactory::getStreamNames over per-type format detectors.

On a table with 25K parts and 7 text indexes it can take extra 20 seconds for DETACH - https://pastila.nl/?003e831c/3bbbdcde32385f1838c52be3e3e48a5b#Kz4Twr1lr+vKqpODx9u+XA==GCM

`MergeTreeIndexFactory::get` per part in `clearCaches` made `DETACH`
slow: `textIndexCreator` builds `ActionsDAG`. Replace with
`MergeTreeIndexFactory::getStreamNames` over per-type format detectors.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [448559d]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan_ubsan, distributed plan, parallel) FAIL
04401_distributed_with_fill_const_to_scalar FAIL cidb
Integration tests (arm_binary, distributed plan, 4/4) FAIL
test_server_startup_and_shutdown_logs/test.py::test_server_no_logging FAIL cidb

AI Review

Summary

This PR refactors secondary-index mark-cache prewarm and eviction to resolve on-disk stream names without constructing index objects, which removes the expensive text-index ActionsDAG build from DETACH/cache-cleanup paths. I did not find a correctness, compatibility, or cache-key regression in the current code: the new detector path preserves the existing minmax/text format resolution logic, and the relevant prewarm / packed-skip-index / detach-attach surfaces are already covered by existing stateless tests.

Final Verdict

✅ No blocking or major issues found in the current diff.

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Jul 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

Both flagged queries (clickbench Q4 at -17.7%, Q15 at -19.3%) look like improvements but were correctly held as no_change: each median lands inside master's current variance band. This PR refactors how on-disk stream names for secondary skip indexes are resolved during index mark-cache load and cleanup, avoiding constructing the index object on those paths. Standard ClickBench Q4/Q15 are plain scan/aggregation queries that don't use secondary indexes, so they can't touch that code, and the ~18-19% deltas are run-to-run variance rather than a real PR effect. No actionable regressions or improvements.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 8231662e-45a1-43b9-a7f3-47f4ba0e64a4
  • MIRAI run: 6897a9a4-08b2-47f9-a218-72762c7ceb0a
  • PR check IDs:
    • clickbench_215097_1783726992
    • clickbench_215103_1783726992
    • clickbench_215109_1783726992
    • tpch_adapted_1_official_215117_1783726992
    • tpch_adapted_1_official_215127_1783726992
    • tpch_adapted_1_official_215134_1783726992

@clickhouse-gh

clickhouse-gh Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 75.20% 85.80% +10.60%
Functions 89.50% 92.70% +3.20%
Branches 65.70% 77.90% +12.20%

Changed lines: Changed C/C++ lines covered: 61/61 (100.00%) · Uncovered code

Full report · Diff report

@rschu1ze

Copy link
Copy Markdown
Member

Hi, I'm coming from #110049. This PR adds a second path textIndexFormatDetector to a very similar one that already exists getDeserializedFormat. The odd function naming aside, I would like to understand first how the expression evaluation of the pre- and postprocessor can be expensive. I mean if the expression contains hundreds of thousands of nested functions, then yes, but most users will have just one or two functions.

@azat

azat commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

I mean if the expression contains hundreds of thousands of nested functions, then yes, but most users will have just one or two functions.

On a table with 25K parts and 7 text indexes it can take extra 20 seconds for DETACH - https://pastila.nl/?003e831c/3bbbdcde32385f1838c52be3e3e48a5b#Kz4Twr1lr+vKqpODx9u+XA==GCM

But in general, creating index object only to get list of files looks like a useless work

@rschu1ze

Copy link
Copy Markdown
Member

That's right. I'm still curious if the pre/postprocessor evaluation were what really caused the slowness. Anyways, I'm not against merging this PR.

@azat

azat commented Jul 13, 2026 •

Copy link
Copy Markdown
Member Author

FWIW I've tested it on my dataset it and it helps, DETACH reduced from 22 sec to 7 sec, will take a look separately

UPD: looks like this is an overhead for destroying 25K parts

@clickhouse-gh clickhouse-gh Bot added the comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. label Sep 4, 2026
@rschu1ze

Copy link
Copy Markdown
Member

Please re-open if this PR is still useful.

@rschu1ze rschu1ze closed this Sep 17, 2026
@clickhouse-gh clickhouse-gh Bot added comp-skip-index Skipping indexes (minmax, set, bloom) and their evaluation. and removed comp-mergetree MergeTree* family: parts, merges, primary index, column statistics, background data transformation. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-skip-index Skipping indexes (minmax, set, bloom) and their evaluation. pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants