This is an automated email from the ASF dual-hosted git repository.
panxiaolei pushed a commit to branch ckb2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/ckb2 by this push:
new adbb7d65d74 only fixed key use group by count(*) opt (#61315)
adbb7d65d74 is described below
commit adbb7d65d7443714ea8270216eec1192f43d2463
Author: Mryange <[email protected]>
AuthorDate: Fri Mar 13 17:51:14 2026 +0800
only fixed key use group by count(*) opt (#61315)
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
---
be/src/exec/common/agg_utils.h | 9 +++++++++
be/src/exec/operator/aggregation_sink_operator.cpp | 2 +-
be/src/exec/operator/streaming_aggregation_operator.cpp | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/be/src/exec/common/agg_utils.h b/be/src/exec/common/agg_utils.h
index fada1b49e30..65d281d99c6 100644
--- a/be/src/exec/common/agg_utils.h
+++ b/be/src/exec/common/agg_utils.h
@@ -77,9 +77,18 @@ struct AggregatedDataVariants
DataWithNullKey> {
AggregatedDataWithoutKey without_key = nullptr;
+ bool is_fixed_key = true;
+
void init(const std::vector<DataTypePtr>& data_types, HashKeyType type) {
bool nullable = data_types.size() == 1 && data_types[0]->is_nullable();
+ if (type == HashKeyType::without_key || type == HashKeyType::EMPTY ||
+ type == HashKeyType::serialized || type ==
HashKeyType::string_key) {
+ is_fixed_key = false;
+ } else {
+ is_fixed_key = true;
+ }
+
switch (type) {
case HashKeyType::without_key:
break;
diff --git a/be/src/exec/operator/aggregation_sink_operator.cpp
b/be/src/exec/operator/aggregation_sink_operator.cpp
index a8d95f58436..43b9364a65d 100644
--- a/be/src/exec/operator/aggregation_sink_operator.cpp
+++ b/be/src/exec/operator/aggregation_sink_operator.cpp
@@ -174,7 +174,7 @@ Status AggSinkLocalState::open(RuntimeState* state) {
p._aggregate_evaluators[0]->function()->is_simple_count()) /* only
one count(*) */
&& !_should_limit_output /* no limit optimization */ &&
!Base::_shared_state->enable_spill /* spill not enabled */) {
- _shared_state->use_simple_count = true;
+ _shared_state->use_simple_count =
_shared_state->agg_data->is_fixed_key;
#ifndef NDEBUG
// Randomly enable/disable in debug mode to verify correctness of
multi-phase agg promotion/demotion.
_shared_state->use_simple_count = rand() % 2 == 0;
diff --git a/be/src/exec/operator/streaming_aggregation_operator.cpp
b/be/src/exec/operator/streaming_aggregation_operator.cpp
index 8ce01aef955..9f9e9910adc 100644
--- a/be/src/exec/operator/streaming_aggregation_operator.cpp
+++ b/be/src/exec/operator/streaming_aggregation_operator.cpp
@@ -156,7 +156,7 @@ Status StreamingAggLocalState::open(RuntimeState* state) {
// The serialization format of count is UInt64 itself, so it can be
inlined into the hash table mapped slot.
if (_aggregate_evaluators.size() == 1 &&
_aggregate_evaluators[0]->function()->is_simple_count()) {
- _use_simple_count = true;
+ _use_simple_count = _agg_data->is_fixed_key;
#ifndef NDEBUG
// Randomly enable/disable in debug mode to verify correctness of
multi-phase agg promotion/demotion.
_use_simple_count = rand() % 2 == 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]