Re: Error when using array_agg with filter where clause in pg16 and pg17

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kaimeh <kkaimeh@gmail.com>, pgsql-bugs@lists.postgresql.org
Date: 2025-04-09T00:54:50Z
Lists: pgsql-bugs
On Wed, 9 Apr 2025 at 12:52, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> David Rowley <dgrowleyml@gmail.com> writes:
> > I suspect we should just leave this for v18 and maybe come back and
> > improve for v19.
>
> I think not doing anything is unacceptable: even though it took awhile
> to notice, presorted_agg flat out breaks some queries that worked
> before.  That trumps any worries about "maybe the plan will be worse",
> and I don't even think it's a close decision.  So my inclination is
> to do the simplest possible thing in v16-v18, and that seems to be
> to disable presorted_agg if there's a FILTER.  Then we can look
> into better ideas at leisure for v19.

Misunderstanding. I meant do nothing about the costing issue. I still
think we should fix the bug, of course. The POC patch I posted is for
that part.

David



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix issue with ORDER BY / DISTINCT aggregates and FILTER

  2. Improve performance of ORDER BY / DISTINCT aggregates