Repository navigation
Conversation
`getReadTaskColumns` built the full PREWHERE execution plan via `MergeTreeSelectProcessor::getPrewhereActions` on every call, and it is called once per part from `MergeTreeReadPoolBase::buildReadTaskInfo`. None of the inputs to that plan are part-specific, so every part rebuilt an identical plan - including `tryBuildPrewhereSteps`, which runs by default - and then threw the compiled `ExpressionActions` away, keeping only the per-step column name lists. Build the `PrewhereExprInfo` once in `MergeTreeReadPoolBase` and pass it to `getReadTaskColumns`. Work that is genuinely per-part stays per-part: required column injection, resolving columns against the part, and the adaptive granularity check. The resulting read task columns are unchanged. Measured on a 710-part table with `max_threads = 8`, median `QueryPipelineBuildMicroseconds`: 0.90 ms -> 0.65 ms for a 5-condition PREWHERE, and 2.06 ms -> 1.42 ms for a 16-condition PREWHERE. The members `row_level_filter`, `prewhere_info` and `actions_settings` of `MergeTreeReadPoolBase` are removed because building the plan in the constructor leaves them without any reader.
5efb1a0 to
fe2f5c6
Compare
|
Workflow [PR], commit [595a62d] Summary: ✅
AI ReviewSummaryThe PR builds the Final VerdictStatus: ✅ Approve. |
…an-out-of-per-part-loop
…an-out-of-per-part-loop
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 46/46 (100.00%) · Uncovered code |
…an-out-of-per-part-loop
…an-out-of-per-part-loop
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units138 translation units recompiled, 2033 s compile time in total, 138 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
# Conflicts: # src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp
…an-out-of-per-part-loop Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ere-plan-out-of-per-part-loop
…an-out-of-per-part-loop # Conflicts: # src/Storages/MergeTree/MergeTreeReadPoolBase.cpp
…an-out-of-per-part-loop # Conflicts: # src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp
getReadTaskColumnsbuilt the full PREWHERE execution plan viaMergeTreeSelectProcessor::getPrewhereActions, and it is called once per part fromMergeTreeReadPoolBase::buildReadTaskInfo. None of the inputs to that plan are part-specific, so every part rebuilt an identical plan — includingtryBuildPrewhereSteps, which runs by default — and then discarded the compiledExpressionActions, keeping only the per-step column name lists. Pipeline building is serial time on the query thread, so this lands directly in query latency on tables with many parts.This builds the
PrewhereExprInfoonce inMergeTreeReadPoolBaseand passes it togetReadTaskColumns. Work that is genuinely per-part stays per-part: required column injection, resolving columns against the part, and the adaptive granularity check. The resulting read task columns are unchanged.Measured on a 710-part table with
max_threads = 8, medianQueryPipelineBuildMicroseconds: 0.90 ms → 0.65 ms for a 5-condition PREWHERE, and 2.06 ms → 1.42 ms for a 16-condition PREWHERE.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reduced query pipeline building time for
MergeTreetables with many parts by constructing the PREWHERE execution plan once per query instead of once per part.Workflow [PR]
Sync PR [sync-upstream/pr/111956]