This is an automated email from the ASF dual-hosted git repository. kxiao pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4d595d548fcc34492396e9d474edec6429e8fff8 Author: HappenLee <happen...@hotmail.com> AuthorDate: Fri Jul 14 00:29:19 2023 +0800 [Agg](exec) support aggregation_node limit short circuit (#21767) --- be/src/vec/exec/vaggregation_node.cpp | 4 ++++ be/src/vec/exec/vaggregation_node.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/be/src/vec/exec/vaggregation_node.cpp b/be/src/vec/exec/vaggregation_node.cpp index 591ad3e55d..5f021e9c95 100644 --- a/be/src/vec/exec/vaggregation_node.cpp +++ b/be/src/vec/exec/vaggregation_node.cpp @@ -151,6 +151,10 @@ Status AggregationNode::init(const TPlanNode& tnode, RuntimeState* state) { // init aggregate functions _aggregate_evaluators.reserve(tnode.agg_node.aggregate_functions.size()); + // In case of : `select * from (select GoodEvent from hits union select CounterID from hits) as h limit 10;` + // only union with limit: we can short circuit query the pipeline exec engine. + _can_short_circuit = + tnode.agg_node.aggregate_functions.empty() && state->enable_pipeline_exec(); TSortInfo dummy; for (int i = 0; i < tnode.agg_node.aggregate_functions.size(); ++i) { diff --git a/be/src/vec/exec/vaggregation_node.h b/be/src/vec/exec/vaggregation_node.h index ce7070b817..b30d1cfa0c 100644 --- a/be/src/vec/exec/vaggregation_node.h +++ b/be/src/vec/exec/vaggregation_node.h @@ -897,6 +897,7 @@ private: std::vector<size_t> _probe_key_sz; std::vector<AggFnEvaluator*> _aggregate_evaluators; + bool _can_short_circuit = false; // may be we don't have to know the tuple id TupleId _intermediate_tuple_id; @@ -1060,6 +1061,10 @@ private: if (_should_limit_output) { _reach_limit = _get_hash_table_size() >= _limit; + if (_reach_limit && _can_short_circuit) { + _can_read = true; + return Status::Error<ErrorCode::END_OF_FILE>(""); + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org