Skip to content

PR: use serialized query plan (part 1) - #88696

Merged
devcrafter merged 53 commits into
masterfrom
pr-serialize-query_plan
Feb 20, 2026
Merged

devcrafter merged 53 commits into
masterfrom
pr-serialize-query_plan

Conversation

@devcrafter

@devcrafter devcrafter commented Oct 16, 2025 •

Copy link
Copy Markdown
Member

Fast tests CI run (with enabled serialize_query_plan) and distributed plan run are passing. Next steps are enabling more tests and removing unnecessary conversion between internal query representations (AST, query tree, query plan). Continue in #97261

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.2.1.979

@clickhouse-gh

clickhouse-gh Bot commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [472e8cd]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 16, 2025
@ClickHouse ClickHouse deleted a comment from clickhouse-gh Bot Jan 9, 2026
devcrafter and others added 24 commits January 9, 2026 15:41
- JOINs with the same MT table
@devcrafter devcrafter changed the title PR: use serialized query plan PR: use serialized query plan (part 1) Feb 18, 2026
@devcrafter
devcrafter requested a review from Copilot February 18, 2026 08:44
@devcrafter
devcrafter marked this pull request as ready for review February 18, 2026 08:44

Copilot AI 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.

Pull request overview

This PR is the first part of switching distributed/parallel-replicas execution to use a serialized QueryPlan (behind serialize_query_plan), and updates several stateless tests to be more robust/cleanup state.

Changes:

  • Add caching APIs to QueryPlan serialization and use cached bytes when sending query plans over the wire.
  • Propagate a QueryPlan through parallel-replicas remote execution paths and preserve context lifetime for storage resolution.
  • Adjust stateless tests and expected EXPLAIN output to cover serialize_query_plan behavior.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/queries/0_stateless/03641_analyzer_issue_85834.sql Add row policy cleanup and drop table at end to avoid test pollution.
tests/queries/0_stateless/03303_distributed_explain.sql Extend distributed EXPLAIN coverage for serialize_query_plan and parallel replicas.
tests/queries/0_stateless/03303_distributed_explain.reference Update expected EXPLAIN output for new sections.
tests/queries/0_stateless/03255_parallel_replicas_join_algo_and_analyzer_4.sh Add defensive DROP TABLE IF EXISTS before creating tables.
tests/queries/0_stateless/03093_reading_bug_with_parallel_replicas.sql Remove settings lines / minor cleanup.
tests/queries/0_stateless/02998_analyzer_prewhere_report.sql Make table name unique and add DROP TABLE IF EXISTS preamble.
src/QueryPipeline/RemoteQueryExecutor.h Add optional QueryPlan parameter to support query-plan stage remotely.
src/QueryPipeline/RemoteQueryExecutor.cpp Wire QueryPlan through constructors and send it when present.
src/Processors/QueryPlan/resolveStorages.cpp Preserve context lifetime in resolved reading plans; propagate parallel-replicas intent via context setting.
src/Processors/QueryPlan/Serialization.cpp Add QueryPlan cached-serialization helpers (ensureSerialized/getSerializedData/isSerialized).
src/Processors/QueryPlan/QueryPlan.h Store cached serialized plan bytes in QueryPlan.
src/Processors/QueryPlan/ReadFromTableStep.h / .cpp Add use_parallel_replicas bit and serialize/deserialize it.
src/Processors/QueryPlan/ReadFromRemote.h / .cpp Pass QueryPlan through parallel remote replicas and use it for distributed plan description.
src/Processors/QueryPlan/ParallelReplicasLocalPlan.h / .cpp Split out remote-plan creation and mark reads as parallel-replicas capable.
src/Planner/findParallelReplicasQuery.cpp Relax follower restriction when serialize_query_plan is enabled.
src/Planner/PlannerJoinTree.cpp Ensure PREWHERE outputs include columns needed by row-policy/additional filters in logical plan.
src/Interpreters/ClusterProxy/executeQuery.cpp Build and pass a remote query plan for parallel replicas when serialization is enabled.
src/Interpreters/ActionsDAG.cpp Fix set registry pointer handling when deserializing constant sets.
src/Client/Connection.cpp Send cached serialized query plan bytes when available.

Comment thread src/Planner/PlannerJoinTree.cpp Resolved
Comment thread src/Planner/PlannerJoinTree.cpp Resolved

@KochetovNicolai KochetovNicolai left a comment

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.

Overall looks good!

@devcrafter
devcrafter added this pull request to the merge queue Feb 20, 2026
Merged via the queue into master with commit 8240cec Feb 20, 2026
143 checks passed
@devcrafter
devcrafter deleted the pr-serialize-query_plan branch February 20, 2026 15:43
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

5 participants