Skip to content

Fix read in order optimization for DESC sorting with FINAL - #46009

Merged
vdimir merged 7 commits into
masterfrom
vdimir/fix_read_in_order_final_desc
Feb 15, 2023
Merged

vdimir merged 7 commits into
masterfrom
vdimir/fix_read_in_order_final_desc

Conversation

@vdimir

@vdimir vdimir commented Feb 3, 2023

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in official stable or prestable release)

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

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

@robot-ch-test-poll robot-ch-test-poll added the pr-bugfix Pull request with bugfix, not backported by default label Feb 3, 2023
@hanfei1991 hanfei1991 self-assigned this Feb 3, 2023
/// If do_not_merge_across_partitions_select_final is true
/// and there is only one part in partition with level > 0
/// then we won't postprocess this part
bool should_read_in_order = !input_order_info || input_order_info->direction == 0;

@hanfei1991 hanfei1991 Feb 6, 2023 •

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.

Only one question: Why should we read in order if input_order_info is null

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My mistake was that it should be should_not_read_in_order.
But anyway, decided to use another solution. We need to disable read-in-order optimization for reverse order with final because it may lead to incorrect final behavior (it may rely on read in direct order). Check out new commits in the PR, please.

@vdimir
vdimir force-pushed the vdimir/fix_read_in_order_final_desc branch from 654e42c to cb5a178 Compare February 9, 2023 11:11

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

rest LGTM

Comment thread src/Storages/StorageMerge.cpp Resolved
Comment thread src/Storages/StorageMerge.cpp Resolved
@vdimir
vdimir merged commit 645fee3 into master Feb 15, 2023
@vdimir
vdimir deleted the vdimir/fix_read_in_order_final_desc branch February 15, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Order by desc issue for ReplacingMergeTree [regress]

3 participants