Skip to content

Don't charge aggregate costs to the DQA dedup HashAggregates - #2261

Open
chenjinbao1989 wants to merge 1 commit into
apache:mainfrom
chenjinbao1989:dqa_cost
Open

chenjinbao1989 wants to merge 1 commit into
apache:mainfrom
chenjinbao1989:dqa_cost

Conversation

@chenjinbao1989

Copy link
Copy Markdown
Contributor

In add_multi_dqas_hash_agg_path(), the HashAggregates that remove duplicates after the TupleSplit only deduplicate their input; they do not run any aggregate transition or final functions. But DedupCost was filled by get_agg_clause_costs() before they were created, so they were charged the costs of all aggregates in the query. Move the call after them, so the dedup aggregates are costed with empty aggregate costs.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


In add_multi_dqas_hash_agg_path(), the HashAggregates that remove
duplicates after the TupleSplit only deduplicate their input; they do
not run any aggregate transition or final functions.  But DedupCost was
filled by get_agg_clause_costs() before they were created, so they were
charged the costs of all aggregates in the query.  Move the call after
them, so the dedup aggregates are costed with empty aggregate costs.
@my-ship-it

Copy link
Copy Markdown
Contributor

Thanks for fixing it and clean up FIXMEs, and some comments below:

  • The commit message says the get_agg_clause_costs() call is moved, but the diff only deletes it, so please reword it to "remove".

  • Please remove the GPDB_14_MERGE_FIXME about DedupCost in gp_dqa.sql/.out (which this PR fixes), and check whether the gp_motion_cost_per_row=2 workaround is still needed.

  • No existing test covers this change, so please add a multi-DQA case whose plan changes because of the fix.

  • The single-DQA dedup HashAggregates are still costed with ctx->agg_partial_costs /* FIXME */ and have the same overcharge, so please consider fixing them here too.

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.

2 participants