Skip to content

branch-4.2:[fix](cost model) scale partitioned scalar aggregate cost by BE number #66354 - #68368

Merged
yiguolei merged 3 commits into
apache:branch-4.2from
feiniaofeiafei:codex/pick-66354-4.2
Sep 23, 2026
Merged

yiguolei merged 3 commits into
apache:branch-4.2from
feiniaofeiafei:codex/pick-66354-4.2

Conversation

@feiniaofeiafei

@feiniaofeiafei feiniaofeiafei commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

picked from #66354

foxtail463 and others added 3 commits September 22, 2026 11:03
…en partitioned (apache#66354)

Problem Summary:
A scalar count(distinct) runs its global aggregate hash-shuffled by the
distinct
key (non-empty partitionExpressions), i.e. in parallel across BEs. But
the cost
model set the parallelism factor from group-by keys alone, so with no
group by it
used factor = 1, costing the aggregate as single-point. This
overestimated the
parallel plan and made CBO reject it.

Solution:
Treat a global aggregate as partitioned when it has group by keys or
non-empty
partitionExpressions, and scale its cost by beNumber accordingly.

---------

Co-authored-by: yangtao555 <yangtao555@jd.com>
(cherry picked from commit 051b9ac)
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@feiniaofeiafei feiniaofeiafei changed the title [branch-4.2][fix](cost model) scale partitioned scalar aggregate cost by BE number (#66354) branch-4.2:[fix](cost model) scale partitioned scalar aggregate cost by BE number (#66354) Sep 22, 2026
@feiniaofeiafei feiniaofeiafei changed the title branch-4.2:[fix](cost model) scale partitioned scalar aggregate cost by BE number (#66354) branch-4.2:[fix](cost model) scale partitioned scalar aggregate cost by BE number #66354 Sep 22, 2026
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@yiguolei
yiguolei merged commit b58e421 into apache:branch-4.2 Sep 23, 2026
48 of 50 checks passed
englefly added a commit to englefly/incubator-doris that referenced this pull request Sep 23, 2026
…tputs after rebase

Rebasing onto the current branch-4.2 brought in
  b58e421 [fix](cost model) scale partitioned scalar aggregate cost by BE number (apache#68368)
which changes the distributed plan of tpcds q16/q94/q95. Those 25 baselines were
touched by both sides, so the rebase conflicted on 22 of them and the merge left
them without the table alias.

Regenerated the whole shape_check tree with -forceGenOut on the rebased tree
(1001 suites, 0 failures) so the baselines carry both the new cost-model plan and
the table alias. Only these 25 files changed: 75 insertions / 75 deletions, every
changed line a pure alias insertion.

Verification:
  - re-run without -forceGenOut: shape_check 1001 suites, 0 failures
  - the 22 suites from the previous commit: 0 failures (cost model change does not
    affect them)
  - alias-stripped, all 998 shape_check .out are byte-identical to
    origin/branch-4.2's committed baselines, i.e. the only delta is the alias
englefly added a commit to englefly/incubator-doris that referenced this pull request Sep 23, 2026
…tputs after rebase

Rebasing onto the current branch-4.2 brought in
  b58e421 [fix](cost model) scale partitioned scalar aggregate cost by BE number (apache#68368)
which changes the distributed plan of tpcds q16/q94/q95. Those 25 baselines were
touched by both sides, so the rebase conflicted on 22 of them and the merge left
them without the table alias.

Regenerated the whole shape_check tree with -forceGenOut on the rebased tree
(1001 suites, 0 failures) so the baselines carry both the new cost-model plan and
the table alias. Only these 25 files changed: 75 insertions / 75 deletions, every
changed line a pure alias insertion.

Verification:
  - re-run without -forceGenOut: shape_check 1001 suites, 0 failures
  - the 22 suites from the previous commit: 0 failures (cost model change does not
    affect them)
  - alias-stripped, all 998 shape_check .out are byte-identical to
    origin/branch-4.2's committed baselines, i.e. the only delta is the alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants