Skip to content

Speed up drop and shutdown of tables with text indexes - #110049

Closed
evillique wants to merge 1 commit into
ClickHouse:masterfrom
evillique:text-index-lazy-preprocessor
Closed

evillique wants to merge 1 commit into
ClickHouse:masterfrom
evillique:text-index-lazy-preprocessor

Conversation

@evillique

Copy link
Copy Markdown
Member

Speed up DROP TABLE, DETACH TABLE, and server shutdown for tables with text indexes: build the preprocessor and postprocessor expressions lazily on first use instead of in the index object constructor, which runs for every data part on part destruction just to compute cache keys.

Related: #97772

Changelog category (leave one):

  • Performance Improvement

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

Speed up DROP TABLE, DETACH TABLE, and server shutdown for tables with text indexes with preprocessor or postprocessor arguments.

@clickhouse-gh

clickhouse-gh Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [9e0b45c]

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
AST fuzzer (arm_asan_ubsan) FAIL
Logical error: '!part.empty()' (STID: 2508-2ef2) FAIL cidb

AI Review

Summary

This PR defers construction of text-index preprocessor / postprocessor helpers until createIndexAggregator or createIndexCondition first needs them, which should remove that expression-analysis cost from metadata-only paths like part destruction. The lazy initialization itself looks reasonable, but the PR is labeled Performance Improvement without any benchmark or before/after measurement demonstrating the claimed DROP TABLE / shutdown speedup, so I cannot approve the performance claim yet.

Tests
  • ⚠️ The added unit test proves the lazy-construction behavior, but it does not measure the promised improvement. Please add a focused benchmark or before/after timings for DROP TABLE, DETACH TABLE, or shutdown on a table with many parts and a text index using preprocessor / postprocessor.
Final Verdict
  • Status: ⚠️ Request changes
  • Please add performance evidence for the claimed speedup. The implementation change itself looks reasonable; the blocker is substantiating the Performance Improvement claim.

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

}

/// Constructing a text index object must not analyze the preprocessor and postprocessor expressions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regression test proves the lazy-construction semantics, but the PR is categorized as Performance Improvement and still does not show that DROP TABLE / DETACH TABLE / shutdown becomes measurably faster on the intended workload. Please add a focused benchmark or at least before/after timings for a table with many text-indexed parts so the changelog claim is backed by data.

@clickhouse-gh

clickhouse-gh Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

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

This PR makes the full-text (text) secondary-index preprocessor/postprocessor build lazily on first real use instead of at index-object construction; the private and public diffs are identical. The standard ClickBench schema has no text index, so neither Q4 nor Q15 executes any changed code. Q15's flagged improvement (-21.8%) is off-path and has been downgraded to not-sure as run-to-run variance, and Q4's -13.5% was already correctly suppressed within master's current variance band [200,281] ms. No credible PR-attributable perf effect on these benchmarks.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 15 not_sure 243 190 -21.8% <0.0001 The PR only defers full-text (text) index processor construction; ClickBench Q15 exercises no text index, so this -21.8% is off-path run-to-run variance, not a PR effect.

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
  • StressHouse run: 99a74ca4-431a-4272-bb55-76edb1edb7ac
  • MIRAI run: 68ceba8a-dfc5-43fe-968b-fdeaad430713
  • PR check IDs:
    • clickbench_213124_1783725524
    • clickbench_213138_1783725524
    • clickbench_213145_1783725524
    • tpch_adapted_1_official_213149_1783725524
    • tpch_adapted_1_official_213157_1783725524
    • tpch_adapted_1_official_213164_1783725524

@clickhouse-gh

clickhouse-gh Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.80% 85.80% +0.00%
Functions 92.70% 92.70% +0.00%
Branches 77.90% 77.90% +0.00%

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

Full report · Diff report

MergeTreeIndexTextPostprocessorPtr postprocessor;

private:
/// Preprocessor and postprocessor construction analyzes expressions, which is expensive.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evillique Did you observe the regression live? How bad is it? And why is it expensive to analyze an expression? I mean, the preprocessor and postprocessors don't apply the expression to data unless a new text index is constructed or a SELECT query runs, but that is not what happens in a drop/shutdown of tables, no?

@@ -0,0 +1,82 @@
#include <gtest/gtest.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A XML performance test will be a lot more declarative and more maintainable than a C++ unit test.

@rschu1ze

Copy link
Copy Markdown
Member

CC: @Ergus who originally introduced the text index pre/postprocessor.

@azat

azat commented Jul 13, 2026

Copy link
Copy Markdown
Member

@rschu1ze unlikely this will fix root cause, this is a better alternative - #110050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request with some performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants