Skip to content

Enable buffering for MergingSorted steps on initiator - #100661

Merged
alexey-milovidov merged 6 commits into
masterfrom
fix_in_order_reading_with_pr
Apr 26, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
fix_in_order_reading_with_pr

Conversation

@nickitat

@nickitat nickitat commented Mar 24, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Performance Improvement

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

Enable buffering for sorting steps on the initiator for distributed queries with sorting.

@clickhouse-gh

clickhouse-gh Bot commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [96bf77f]

Summary: ✅


AI Review

Summary

This PR enables buffering for initiator-side MergingSorted steps in distributed ORDER BY flows (both analyzer and legacy planner paths), plumbs SortingStep::Settings into the MergingSorted constructor, and ensures updateLimit disables buffering once a limit is pushed down. The added stateless test asserts BufferChunks in the distributed+parallel-replicas pipeline, and I did not find additional correctness, safety, or performance issues that require changes.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Mar 24, 2026
@nickitat nickitat changed the title Fix in order reading with pr Enable buffering for MergingSorted steps on initiator Apr 20, 2026
@nickitat
nickitat marked this pull request as ready for review April 22, 2026 15:57
@clickhouse-gh

clickhouse-gh Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 91.10% 91.10% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 97.56% (40/41) · Uncovered code

Full report · Diff report

@alexey-milovidov alexey-milovidov 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.

Looks good!

@alexey-milovidov alexey-milovidov self-assigned this Apr 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Apr 26, 2026
Merged via the queue into master with commit 5578ef4 Apr 26, 2026
316 of 318 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix_in_order_reading_with_pr branch April 26, 2026 14:28
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 26, 2026
@PedroTadim

Copy link
Copy Markdown
Member

Hello! Performance tests are missing?

SET automatic_parallel_replicas_mode = 0;
SET enable_parallel_replicas=2, max_parallel_replicas=2, cluster_for_parallel_replicas='test_cluster_one_shard_two_replicas', parallel_replicas_for_non_replicated_merge_tree=1, parallel_replicas_local_plan=1;

explain pipeline distributed=1 SELECT * FROM test_distributed_pipeline ORDER BY c;

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.

Hello! Besides the explain you should add the query without it to verify correctness

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

4 participants