Skip to content

Fuse some aggregate functions #20091

@alexey-milovidov

Description

@alexey-milovidov

Add aggregate function sumCount. This function returns a tuple of two fields: sum and count.

Add a setting optimize_fuse_sum_count_avg.
If it is enabled and query contains at least two aggregate functions from sum, count, avg of identical arguments, rewrite them to sumCount(x).1, sumCount(x).2, sumCount(x).1 / sumCount(x).2.

This setting should not be enabled by default to avoid incompatibilities in clusters where new and old server versions may work at the same time.

Further directions

Multiple quantile functions can be fused to single quantiles.

Alternatives

Compiled aggregator that we already had years ago but removed.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions