mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Change the way reading in order is requested from plan optimizations
This commit is contained in:
parent
9ea277c047
commit
6551966dc7
@ -79,11 +79,8 @@ size_t tryDistinctReadInOrder(QueryPlan::Node * parent_node, QueryPlan::Nodes &)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/// update input order info in read_from_merge_tree step
|
/// update input order info in read_from_merge_tree step
|
||||||
const int direction = output_sort_desc.front().direction; /// for DISTINCT direction doesn't matter, so use current direction
|
const int direction = 0; /// for DISTINCT direction doesn't matter, ReadFromMergeTree will choose proper one
|
||||||
/// example: SELECT DISTINCT a from t ORDER BY a DESC;
|
read_from_merge_tree->requestReadingInOrder(number_of_sorted_distinct_columns, direction, pre_distinct->getLimitHint());
|
||||||
InputOrderInfoPtr order_info
|
|
||||||
= std::make_shared<const InputOrderInfo>(SortDescription{}, number_of_sorted_distinct_columns, direction, pre_distinct->getLimitHint());
|
|
||||||
read_from_merge_tree->setQueryInfoInputOrderInfo(order_info);
|
|
||||||
|
|
||||||
/// update data stream's sorting properties for found transforms
|
/// update data stream's sorting properties for found transforms
|
||||||
const DataStream * input_stream = &read_from_merge_tree->getOutputStream();
|
const DataStream * input_stream = &read_from_merge_tree->getOutputStream();
|
||||||
|
@ -101,7 +101,7 @@ size_t tryReuseStorageOrderingForWindowFunctions(QueryPlan::Node * parent_node,
|
|||||||
|
|
||||||
if (order_info)
|
if (order_info)
|
||||||
{
|
{
|
||||||
read_from_merge_tree->setQueryInfoInputOrderInfo(order_info);
|
read_from_merge_tree->requestReadingInOrder(order_info->used_prefix_of_sorting_key_size, order_info->direction, order_info->limit);
|
||||||
sorting->convertToFinishSorting(order_info->sort_description_for_merging);
|
sorting->convertToFinishSorting(order_info->sort_description_for_merging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,16 +1018,17 @@ MergeTreeDataSelectAnalysisResultPtr ReadFromMergeTree::selectRangesToRead(
|
|||||||
return std::make_shared<MergeTreeDataSelectAnalysisResult>(MergeTreeDataSelectAnalysisResult{.result = std::move(result)});
|
return std::make_shared<MergeTreeDataSelectAnalysisResult>(MergeTreeDataSelectAnalysisResult{.result = std::move(result)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadFromMergeTree::setQueryInfoInputOrderInfo(InputOrderInfoPtr order_info)
|
void ReadFromMergeTree::requestReadingInOrder(size_t prefix_size, int direction, size_t limit)
|
||||||
{
|
{
|
||||||
|
/// if dirction is not set, use current one
|
||||||
|
if (!direction)
|
||||||
|
direction = getSortDirection();
|
||||||
|
|
||||||
|
auto order_info = std::make_shared<InputOrderInfo>(SortDescription{}, prefix_size, direction, limit);
|
||||||
if (query_info.projection)
|
if (query_info.projection)
|
||||||
{
|
|
||||||
query_info.projection->input_order_info = order_info;
|
query_info.projection->input_order_info = order_info;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
query_info.input_order_info = order_info;
|
query_info.input_order_info = order_info;
|
||||||
}
|
|
||||||
|
|
||||||
/// update sort info for output stream
|
/// update sort info for output stream
|
||||||
SortDescription sort_description;
|
SortDescription sort_description;
|
||||||
|
@ -151,7 +151,7 @@ public:
|
|||||||
const SelectQueryInfo & getQueryInfo() const { return query_info; }
|
const SelectQueryInfo & getQueryInfo() const { return query_info; }
|
||||||
StorageMetadataPtr getStorageMetadata() const { return metadata_for_reading; }
|
StorageMetadataPtr getStorageMetadata() const { return metadata_for_reading; }
|
||||||
|
|
||||||
void setQueryInfoInputOrderInfo(InputOrderInfoPtr order_info);
|
void requestReadingInOrder(size_t prefix_size, int direction, size_t limit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getSortDirection() const
|
int getSortDirection() const
|
||||||
|
Loading…
Reference in New Issue
Block a user