Skip to content

Show the shipped plan fragment of ReadFromParallelReplicas only with EXPLAIN distributed = 1 - #130779

Open
devcrafter wants to merge 5 commits into
masterfrom
pr-explain-fragment-subtree
Open

devcrafter wants to merge 5 commits into
masterfrom
pr-explain-fragment-subtree

Conversation

@devcrafter

@devcrafter devcrafter commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Related: #130355

With plan-based parallel replicas (parallel_replicas_plan_based), ReadFromParallelReplicas put a multi-line dump of the shipped plan fragment, with headers, into its step description. That broke the tree of every EXPLAIN, and with distributed = 1 the fragment was printed a second time.

Now the description lists only the replicas, and the fragment is printed only with EXPLAIN distributed = 1, under the step. A plain EXPLAIN shows the plan that runs on the initiator; the fragment is shown as shipped, before the replicas optimize it, so for example a projection a replica picks is not visible in it. The query text sent to the replicas is unchanged.

EXPLAIN SELECT b, count() FROM t GROUP BY b

MergingAggregated (merge)
│  Keys: b
│  Aggregates: count()
│  Mode: memory-efficient
└──ReadFromParallelReplicas (Replicas: 127.0.0.3:9000, 127.0.0.1:9000, 127.0.0.2:9000)

EXPLAIN distributed = 1 SELECT b, count() FROM t GROUP BY b

Expression ((Project names + Projection))
  MergingAggregated (merge)
    ReadFromParallelReplicas (Replicas: 127.0.0.3:9000, 127.0.0.1:9000, 127.0.0.2:9000)
      BlocksMarshalling
        Aggregating
          Expression ((Before GROUP BY + Change column names to column identifiers))
            ReadFromMergeTree (default.t)

Tests which check the fragment use EXPLAIN distributed = 1 now: 05138, 05214, 05215, 05238, 05239, 05240, 05293, 05546, 05569, 05812. 05055 matched the old description text.

Changelog category (leave one):

  • Improvement

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

With plan-based parallel replicas, EXPLAIN no longer prints the plan fragment sent to the replicas in the description of ReadFromParallelReplicas; EXPLAIN distributed = 1 shows it as a subtree.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/130779]

…cas` in EXPLAIN

The step description was a multi-line dump of the fragment that broke the plan tree; it now lists only the replicas.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6f3c00d]

Summary: ✅


AI Review

Summary

Reviewed #130779 at 6f3c00d7a783a32529c8793f99352e2c7bc63fde, including all prior discussion, the full diff, and surrounding code. The change keeps the ReadFromParallelReplicas description to replica addresses and uses the existing EXPLAIN distributed = 1 rendering for shipped fragments. No actionable findings. All 11 modified stateless SQL tests passed in the current-head Fast test report.

Description consumers traced: text and JSON EXPLAIN, fragment-tree rendering, CapturedPlan, and processor profiling accept the shorter description as text. EXPLAIN PIPELINE uses its separate renderer. Remote query text still comes from the unchanged dumpQueryPlanShape call; distributed fragment rendering still uses describeDistributedPlan.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-improvement Pull request with some product improvements comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). labels Nov 11, 2026
devcrafter and others added 2 commits November 21, 2026 23:36
A plain `EXPLAIN` now names only the replicas in the `ReadFromParallelReplicas` description. Tests which check
the fragment use `distributed = 1`; the references changed for the subtree go back to master.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@devcrafter devcrafter changed the title Show the shipped plan fragment as a subtree of ReadFromParallelReplicas in EXPLAIN Show the shipped plan fragment of ReadFromParallelReplicas only with EXPLAIN distributed = 1 Nov 22, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 6f3c00d7a with master 3dac6f430 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 14 s compile time in total, 7 of them have a recent master baseline.

Job report

@devcrafter
devcrafter requested a review from groeneai November 23, 2026 19:13

@groeneai groeneai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed this against master and it looks good to me. The query text sent to the replicas still comes from dumpQueryPlanShape, and ReadFromParallelReplicasStep::describeDistributedPlan already prints the fragment with the user's EXPLAIN options. 05138 also gets stronger: Element filter is now checked in the fragment itself instead of being inferred from a missing Filter (WHERE).

One consequence the PR text does not mention. On master, EXPLAIN json = 1 carries the fragment in the Description of ReadFromParallelReplicas (cut at query_plan_max_step_description_length, 500 bytes by default). With this PR the fragment does not reach JSON at all, because EXPLAIN json = 1, distributed = 1 throws Option 'distributed' is not supported with option 'json'. (NOT_IMPLEMENTED) (checked on a master build). Given the truncation this is probably fine, but the changelog entry could say that JSON no longer shows the fragment.

This branch has not been deployed

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

Labels

comp-parallel-replicas Parallel reading from replicas for query speed (not data replication consistency). pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants