From 394c2f708de0413b81cd46c9a228afb1b905782d Mon Sep 17 00:00:00 2001 From: Igor Nikonov Date: Tue, 20 Sep 2022 13:30:27 +0000 Subject: [PATCH 1/2] ReadFromMergeTree: reading in order only if input order info is provided - remove checking optimize*in*order settings, input order info should be set only if a corresponding optimization is enabled and applicable --- src/Processors/QueryPlan/ReadFromMergeTree.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Processors/QueryPlan/ReadFromMergeTree.cpp b/src/Processors/QueryPlan/ReadFromMergeTree.cpp index 60bf8d6a15c..e95b6e801c0 100644 --- a/src/Processors/QueryPlan/ReadFromMergeTree.cpp +++ b/src/Processors/QueryPlan/ReadFromMergeTree.cpp @@ -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; else output_stream->sort_scope = DataStream::SortScope::Chunk; @@ -1008,7 +1007,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; @@ -1119,7 +1118,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), From 757736679f02e3c1483420d29e90bac67098ee37 Mon Sep 17 00:00:00 2001 From: Igor Nikonov Date: Tue, 20 Sep 2022 14:53:45 +0000 Subject: [PATCH 2/2] Fix build --- src/Processors/QueryPlan/ReadFromMergeTree.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Processors/QueryPlan/ReadFromMergeTree.cpp b/src/Processors/QueryPlan/ReadFromMergeTree.cpp index e95b6e801c0..3afb78989fc 100644 --- a/src/Processors/QueryPlan/ReadFromMergeTree.cpp +++ b/src/Processors/QueryPlan/ReadFromMergeTree.cpp @@ -1096,7 +1096,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())