Skip to content

sql: create new aggregate function array_concat_agg #97502

@rytaft

Description

@rytaft

Is your feature request related to a problem? Please describe.
Currently, if you want to aggregate multiple arrays from different rows into a single array, you first need to unnest all the arrays, and then re-aggregate them using array_agg. This often requires a LATERAL join, which may not be possible to decorrelate, resulting in a very inefficient plan. This issue is currently affecting the performance of the SQL activity page in the DB console.

Describe the solution you'd like
We should create a new builtin aggregate function called array_concat_agg, that allows a user to directly aggregate a set of arrays into a single array.

Describe alternatives you've considered
The alternative is to continue using unnest + array_agg, which as described above, is inefficient.

cc @maryliag

Jira issue: CRDB-24730

Metadata

Metadata

Assignees

Labels

C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions