Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mbm with aio on top of query plan #45892

Merged

Conversation

nickitat
Copy link
Member

@nickitat nickitat commented Feb 1, 2023

Changelog category (leave one):

  • Improvement

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

Improved how memory bound merging and aggregation in order on top query plan interact. Previously we fell back to explicit sorting for AIO in some cases when it wasn't actually needed. So it is a perf issue, not a correctness one.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

When initiator choses AIO it sends special setting force_aggregation_in_order to remote nodes. Previously it led to insertion of explicit sorting step into the plan if group_by_info == nullptr (e.g. when query_plan_aggregation_in_order == true). In this case optimisation on top of plan wasn't applied because it doesn't expect SortingStep in between AggregatingStep and Read*Step. It led to not using reading in order and we were need to sort explicitly.
Now we will not insert SortingStep (sorting transforms will be added by AggregatingStep if needed) and should correctly initiate reading in order.

@robot-ch-test-poll robot-ch-test-poll added the pr-improvement Pull request with some product improvements label Feb 1, 2023
@devcrafter devcrafter self-assigned this Feb 1, 2023
@nickitat nickitat force-pushed the fix_mbm_with_aio_on_top_of_query_plan branch from be63bb4 to b39a653 Compare February 1, 2023 18:12
@nickitat nickitat marked this pull request as ready for review February 2, 2023 14:24
@nickitat nickitat force-pushed the fix_mbm_with_aio_on_top_of_query_plan branch from e82c5e5 to a4cee17 Compare February 3, 2023 22:32
@nickitat nickitat force-pushed the fix_mbm_with_aio_on_top_of_query_plan branch from 5c523ba to 74c7816 Compare February 6, 2023 11:27
@nickitat nickitat force-pushed the fix_mbm_with_aio_on_top_of_query_plan branch from 74c7816 to 8a14081 Compare February 6, 2023 22:09
WHERE query_id IN (SELECT query_id FROM system.query_log WHERE query_id != '$1' AND initial_query_id = '$1' AND event_date >= yesterday())
AND event_date >= yesterday() AND logger_name = 'MergeTreeInOrderSelectProcessor'"
}

Copy link
Member

Choose a reason for hiding this comment

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

It'd be nice to have comments what exactly the tests are checking

SELECT URL, EventDate, max(URL)
FROM remote(test_cluster_one_shard_two_replicas, test.hits)
WHERE CounterID = 1704509 AND UserID = 4322253409885123546
GROUP BY CounterID, URL, EventDate, EventDate
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
GROUP BY CounterID, URL, EventDate, EventDate
GROUP BY CounterID, URL, EventDate

SELECT URL, EventDate, max(URL)
FROM remote(test_cluster_one_shard_two_replicas, test.hits)
WHERE CounterID = 1704509 AND UserID = 4322253409885123546
GROUP BY URL, EventDate, EventDate
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
GROUP BY URL, EventDate, EventDate
GROUP BY URL, EventDate

Copy link
Member

@devcrafter devcrafter left a comment

Choose a reason for hiding this comment

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

LGTM with comments

@nickitat
Copy link
Member Author

wow, all green )

@nickitat nickitat merged commit cbd10c4 into ClickHouse:master Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants