mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Disable virtual row better.
This commit is contained in:
parent
b1c46db1b9
commit
e3890a9de1
@ -124,7 +124,7 @@ SortingProperty applyOrder(QueryPlan::Node * parent, SortingProperty * propertie
|
||||
auto common_prefix = commonPrefix(properties->sort_description, sorting_step->getSortDescription());
|
||||
if (!common_prefix.empty())
|
||||
/// Buffering is useful for reading from MergeTree, and it is applied in optimizeReadInOrder only.
|
||||
sorting_step->convertToFinishSorting(common_prefix, /*use_buffering*/ false);
|
||||
sorting_step->convertToFinishSorting(common_prefix, /*use_buffering*/ false, false);
|
||||
}
|
||||
|
||||
auto scope = sorting_step->hasPartitions() ? SortingProperty::SortScope::Stream : SortingProperty::SortScope::Global;
|
||||
|
@ -899,7 +899,7 @@ InputOrder buildInputOrderFromUnorderedKeys(
|
||||
return order_info;
|
||||
}
|
||||
|
||||
InputOrderInfoPtr buildInputOrderInfo(SortingStep & sorting, QueryPlan::Node & node)
|
||||
InputOrderInfoPtr buildInputOrderInfo(SortingStep & sorting, bool & apply_virtual_row, QueryPlan::Node & node)
|
||||
{
|
||||
QueryPlan::Node * reading_node = findReadingStep(node, /*allow_existing_order=*/ false);
|
||||
if (!reading_node)
|
||||
@ -925,6 +925,8 @@ InputOrderInfoPtr buildInputOrderInfo(SortingStep & sorting, QueryPlan::Node & n
|
||||
|
||||
if (order_info.input_order)
|
||||
{
|
||||
apply_virtual_row = order_info.virtual_row_conversion != std::nullopt;
|
||||
|
||||
bool can_read = reading->requestReadingInOrder(
|
||||
order_info.input_order->used_prefix_of_sorting_key_size,
|
||||
order_info.input_order->direction,
|
||||
@ -1128,6 +1130,8 @@ void optimizeReadInOrder(QueryPlan::Node & node, QueryPlan::Nodes & nodes)
|
||||
if (sorting->getType() != SortingStep::Type::Full)
|
||||
return;
|
||||
|
||||
bool apply_virtual_row = false;
|
||||
|
||||
if (typeid_cast<UnionStep *>(node.children.front()->step.get()))
|
||||
{
|
||||
auto & union_node = node.children.front();
|
||||
@ -1150,7 +1154,7 @@ void optimizeReadInOrder(QueryPlan::Node & node, QueryPlan::Nodes & nodes)
|
||||
|
||||
for (auto * child : union_node->children)
|
||||
{
|
||||
infos.push_back(buildInputOrderInfo(*sorting, *child));
|
||||
infos.push_back(buildInputOrderInfo(*sorting, apply_virtual_row, *child));
|
||||
|
||||
if (infos.back())
|
||||
{
|
||||
@ -1202,13 +1206,13 @@ void optimizeReadInOrder(QueryPlan::Node & node, QueryPlan::Nodes & nodes)
|
||||
}
|
||||
}
|
||||
|
||||
sorting->convertToFinishSorting(*max_sort_descr, use_buffering);
|
||||
sorting->convertToFinishSorting(*max_sort_descr, use_buffering, false);
|
||||
}
|
||||
else if (auto order_info = buildInputOrderInfo(*sorting, *node.children.front()))
|
||||
else if (auto order_info = buildInputOrderInfo(*sorting, apply_virtual_row, *node.children.front()))
|
||||
{
|
||||
/// Use buffering only if have filter or don't have limit.
|
||||
bool use_buffering = order_info->limit == 0;
|
||||
sorting->convertToFinishSorting(order_info->sort_description_for_merging, use_buffering);
|
||||
sorting->convertToFinishSorting(order_info->sort_description_for_merging, use_buffering, apply_virtual_row);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1350,7 +1354,7 @@ size_t tryReuseStorageOrderingForWindowFunctions(QueryPlan::Node * parent_node,
|
||||
bool can_read = read_from_merge_tree->requestReadingInOrder(order_info->used_prefix_of_sorting_key_size, order_info->direction, order_info->limit, {});
|
||||
if (!can_read)
|
||||
return 0;
|
||||
sorting->convertToFinishSorting(order_info->sort_description_for_merging, false);
|
||||
sorting->convertToFinishSorting(order_info->sort_description_for_merging, false, false);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -147,11 +147,12 @@ void SortingStep::updateLimit(size_t limit_)
|
||||
}
|
||||
}
|
||||
|
||||
void SortingStep::convertToFinishSorting(SortDescription prefix_description_, bool use_buffering_)
|
||||
void SortingStep::convertToFinishSorting(SortDescription prefix_description_, bool use_buffering_, bool apply_virtual_row_conversions_)
|
||||
{
|
||||
type = Type::FinishSorting;
|
||||
prefix_description = std::move(prefix_description_);
|
||||
use_buffering = use_buffering_;
|
||||
apply_virtual_row_conversions = apply_virtual_row_conversions_;
|
||||
}
|
||||
|
||||
void SortingStep::scatterByPartitionIfNeeded(QueryPipelineBuilder& pipeline)
|
||||
@ -255,7 +256,10 @@ void SortingStep::mergingSorted(QueryPipelineBuilder & pipeline, const SortDescr
|
||||
/*max_block_size_bytes=*/0,
|
||||
SortingQueueStrategy::Batch,
|
||||
limit_,
|
||||
always_read_till_end);
|
||||
always_read_till_end,
|
||||
nullptr,
|
||||
false,
|
||||
apply_virtual_row_conversions);
|
||||
|
||||
pipeline.addTransform(std::move(transform));
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
bool hasPartitions() const { return !partition_by_description.empty(); }
|
||||
|
||||
void convertToFinishSorting(SortDescription prefix_description, bool use_buffering_);
|
||||
void convertToFinishSorting(SortDescription prefix_description, bool use_buffering_, bool apply_virtual_row_conversions_);
|
||||
|
||||
Type getType() const { return type; }
|
||||
const Settings & getSettings() const { return sort_settings; }
|
||||
@ -128,6 +128,7 @@ private:
|
||||
UInt64 limit;
|
||||
bool always_read_till_end = false;
|
||||
bool use_buffering = false;
|
||||
bool apply_virtual_row_conversions = false;
|
||||
|
||||
Settings sort_settings;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user