Skip to content

Add EXPLAIN PIPELINE option to compact repeated processor chains - #104662

Merged
Fgrtue merged 13 commits into
ClickHouse:masterfrom
niyue:bugfix/explain-join
May 29, 2026
Merged

Fgrtue merged 13 commits into
ClickHouse:masterfrom
niyue:bugfix/explain-join

Conversation

@niyue

@niyue niyue commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Group right-side join processors by pipeline layer so EXPLAIN PIPELINE renders parallel FillingRightJoinSide and SimpleSquashingTransform processors compactly instead of as an interleaved nested tower.

Fixes #102998

Changelog category:

  • Improvement

Changelog entry:

  • Add EXPLAIN PIPELINE option to compact repeated processor chains

Note

Low Risk
Changes are limited to EXPLAIN PIPELINE text rendering and option plumbing (including distributed explain propagation), with no impact on query execution semantics.

Overview
Adds a new EXPLAIN PIPELINE boolean setting, compact_repeated_processor_chains, which detects adjacent repeated processor chains and prints them once with an aligned repetition marker (improving readability for parallel joins).

Plumbs the option from InterpreterExplainQuery through QueryPlan::ExplainPipelineOptions and IQueryPlanStep::FormatSettings, and ensures it is forwarded when rendering distributed pipelines from ReadFromRemote. Documentation and a new stateless test cover the expected compacted output.

Reviewed by Cursor Bugbot for commit 82cdb97. Bugbot is set up for automated code reviews on this repo. Configure here.

Version info

  • Merged into: 26.6.1.236

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 12, 2026
@alexey-milovidov
alexey-milovidov requested a review from Fgrtue May 12, 2026 15:49
@clickhouse-gh

clickhouse-gh Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f507e4e]

Summary: ❌

job_name test_name status info comment
Stress test (arm_debug) FAIL
Assertion 'px != 0' failed (STID: 3685-4830) FAIL cidb IGNORED

AI Review

Summary

This PR adds an opt-in EXPLAIN PIPELINE setting, compact_repeated_processor_chains, to render adjacent repeated processor chains compactly, forwards it to distributed pipeline explains only when enabled, and adds documentation plus focused stateless coverage. The current diff addresses the prior header = 1 compaction concern by comparing output headers before collapsing processors, and I did not find remaining code correctness issues.

PR Metadata

💡 The Changelog category of Improvement is appropriate, and a Changelog entry is required. The current entry is a bit too broad because the new rendering is disabled by default, so users only get the improved output when they opt in. Suggested replacement:

- Added the opt-in `EXPLAIN PIPELINE` setting `compact_repeated_processor_chains` to compact repeated processor chains in parallel join pipelines.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 12, 2026
@Fgrtue Fgrtue self-assigned this May 12, 2026

@Fgrtue Fgrtue left a comment

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.

Thank you for contribution! The solutions should be implemented in a different part of code -- we just want to see EXPLAIN slghtly different, not to change the way the pipeline is built.

Calculate processor graph layers in `IQueryPlanStep::describePipeline` so parallel processors are grouped for display without changing processor construction order.
@niyue
niyue force-pushed the bugfix/explain-join branch from ad060ec to f9807f3 Compare May 14, 2026 10:45

@Fgrtue Fgrtue left a comment

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 is a good approach. The result also looks good. However, we should add a setting that will control this behavior. This could be a setting in the EXPLAIN PIPELINE, that users could turn on and off if they want to. By default, let's turn if off by now. So the old tests don't need to be fixed. Also please add a new test, that will test this new setting.

niyue added 2 commits May 16, 2026 05:34
Add `compact_repeated_processor_chains` for `EXPLAIN PIPELINE` so repeated processor chain rendering is opt-in for now.

Keep the default output compatible with existing references and add a new stateless test for the enabled setting.

Issue: ClickHouse#102998
@niyue

niyue commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

This is a good approach. The result also looks good. However, we should add a setting that will control this behavior. This could be a setting in the EXPLAIN PIPELINE, that users could turn on and off if they want to. By default, let's turn if off by now. So the old tests don't need to be fixed. Also please add a new test, that will test this new setting.

@Fgrtue A new setting called compact_repeated_processor_chains is introduced for EXPLAIN PIPELINE to enable this process, and it is off by default. e.g.

EXPLAIN PIPELINE compact_repeated_processor_chains = 1
SELECT * FROM
(
    SELECT * FROM system.numbers LIMIT 100000
) t1
ALL LEFT JOIN
(
    SELECT * FROM system.numbers LIMIT 100000
) t2
USING number
SETTINGS max_threads=16;

@niyue
niyue requested a review from Fgrtue May 22, 2026 00:36

@Fgrtue Fgrtue left a comment

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.

Good! Only one thing left -- documentation. Could you add it to the other settings for EXPLAIN PIPELINE in docs/en/sql-reference/statements/explain.md please?

@niyue

niyue commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@Fgrtue Documentation is updated, could you please check it out? Thanks.

@clickhouse-gh

clickhouse-gh Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 77.00% 77.00% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 159/169 (94.08%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@Fgrtue

Fgrtue commented May 29, 2026

Copy link
Copy Markdown
Contributor

The failed test Stress test (arm_debug) is unrelated to this PR and should be fixed by #106096, so I am merging this pull request.

@Fgrtue
Fgrtue added this pull request to the merge queue May 29, 2026
Merged via the queue into ClickHouse:master with commit 3087a92 May 29, 2026
164 of 167 checks passed
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @niyue @Fgrtue — a couple of suggestions to make this PR easier for reviewers and the changelog reader.

Title (currently misleading):

  • Current: Fix join processor grouping
  • Why: The title 'Fix join processor grouping' implies a fix to join execution/semantics, but the PR only changes EXPLAIN PIPELINE text rendering and adds an opt-in compact_repeated_processor_chains display option. It is also categorized as Improvement, not a Bug Fix.
  • Suggested: Add EXPLAIN PIPELINE option to compact repeated processor chains

Ignore this if the current title/body is intentional.

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

Labels

can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EXPLAIN PIPELINE renders interleaved processors as a nested tower instead of grouping them

5 participants