mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 17:32:32 +00:00
Skip sorting step if input stream is globally sorted
This commit is contained in:
parent
d0e6f8ebc1
commit
67ce421e38
@ -87,6 +87,13 @@ struct SortColumnDescriptionWithColumnIndex
|
||||
: base(std::move(description_)), column_number(column_number_)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const SortColumnDescriptionWithColumnIndex & other) const
|
||||
{
|
||||
return base == other.base && column_number == other.column_number;
|
||||
}
|
||||
|
||||
bool operator!=(const SortColumnDescriptionWithColumnIndex & other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
class CompiledSortDescriptionFunctionHolder;
|
||||
@ -102,6 +109,21 @@ public:
|
||||
std::shared_ptr<CompiledSortDescriptionFunctionHolder> compiled_sort_description_holder;
|
||||
size_t min_count_to_compile_sort_description = 3;
|
||||
bool compile_sort_description = false;
|
||||
|
||||
bool operator==(const SortDescription & other) const
|
||||
{
|
||||
if (size() != other.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < size(); ++i)
|
||||
{
|
||||
if ((*this)[i] != other[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const SortDescription & other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
/** Compile sort description for header_types.
|
||||
|
@ -113,6 +113,10 @@ void SortingStep::convertToFinishSorting(SortDescription prefix_description_)
|
||||
|
||||
void SortingStep::transformPipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
|
||||
{
|
||||
if (input_streams.back().sort_mode == DataStream::SortMode::Stream
|
||||
&& input_streams.back().sort_description == output_stream->sort_description)
|
||||
return;
|
||||
|
||||
if (type == Type::FinishSorting)
|
||||
{
|
||||
bool need_finish_sorting = (prefix_description.size() < result_description.size());
|
||||
|
Loading…
Reference in New Issue
Block a user