Merge pull request #41574 from ClickHouse/igor/use_only_input_order_info

ReadFromMergeTree: reading in order only if input order info is provided
This commit is contained in:
Igor Nikonov 2022-09-21 15:36:51 +02:00 committed by GitHub
commit c849dd4c76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,8 +141,7 @@ ReadFromMergeTree::ReadFromMergeTree(
}
if (!sort_description.empty())
{
auto const & settings = context->getSettingsRef();
if ((settings.optimize_read_in_order || settings.optimize_aggregation_in_order) && query_info.getInputOrderInfo())
if (query_info.getInputOrderInfo())
{
output_stream->sort_scope = DataStream::SortScope::Stream;
const size_t used_prefix_of_sorting_key_size = query_info.getInputOrderInfo()->used_prefix_of_sorting_key_size;
@ -1013,7 +1012,7 @@ MergeTreeDataSelectAnalysisResultPtr ReadFromMergeTree::selectRangesToRead(
result.selected_rows = sum_rows;
const auto & input_order_info = query_info.getInputOrderInfo();
if ((settings.optimize_read_in_order || settings.optimize_aggregation_in_order) && input_order_info)
if (input_order_info)
result.read_type = (input_order_info->direction > 0) ? ReadType::InOrder
: ReadType::InReverseOrder;
@ -1102,7 +1101,6 @@ void ReadFromMergeTree::initializePipeline(QueryPipelineBuilder & pipeline, cons
Pipe pipe;
const auto & settings = context->getSettingsRef();
const auto & input_order_info = query_info.getInputOrderInfo();
if (select.final())
@ -1124,7 +1122,7 @@ void ReadFromMergeTree::initializePipeline(QueryPipelineBuilder & pipeline, cons
column_names_to_read,
result_projection);
}
else if ((settings.optimize_read_in_order || settings.optimize_aggregation_in_order || settings.optimize_read_in_window_order) && input_order_info)
else if (input_order_info)
{
pipe = spreadMarkRangesAmongStreamsWithOrder(
std::move(result.parts_with_ranges),