Performance: Use a specialized sum accumulator for retractable aggregregates #6888
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #6878
Rationale for this change
I noticed this while working on #4973
The
SUM
accumulator is general (it can handle sliding windows) but to be general it carries through an extra count for each group in the "state" -- this count is ignored. For low cardinality groups this likely isn't a problem but for large cardinality groups creating and carrying through the counts takes a measurable amount of time (I saw it in #6800)What changes are included in this PR?
Use a specialized sum accumulator for retractable windows and only track the counts there. For non
Are these changes tested?
Existing coverage
Performance (the bigger changes like
q15 have a
sum` in them, so the change is plausible). The smaller changes don't have any sums which makes me suspiciousAre there any user-facing changes?
a little faster performance. I really expect this to help the code in #6800 so I can simplify the sum accumulator