Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: create new aggregate function array_concat_agg #97502

Closed
rytaft opened this issue Feb 22, 2023 · 0 comments · Fixed by #97826
Closed

sql: create new aggregate function array_concat_agg #97502

rytaft opened this issue Feb 22, 2023 · 0 comments · Fixed by #97826
Assignees
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team

Comments

@rytaft
Copy link
Collaborator

rytaft commented Feb 22, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants