Re: PATCH: decreasing memory needlessly consumed by array_agg - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: PATCH: decreasing memory needlessly consumed by array_agg
Date
Msg-id 1424588701.12308.242.camel@jeff-desktop
Whole thread Raw
In response to Re: PATCH: decreasing memory needlessly consumed by array_agg  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On Sun, 2015-02-22 at 03:14 +0100, Tomas Vondra wrote:
> >>   SELECT COUNT(x) FROM (
> >>      SELECT a, array_agg(i) AS x FRM test GROUP BY 1
> >>   ) foo;
> > 
> > That's actually a bogus test -- array_agg is never executed.
> 
> Really? How could that happen when the result of array_agg() is passed
> to the COUNT()? Also, how could that allocate huge amounts of memory and
> get killed by OOM, which happens easily with this query?

Oops, I misread that as "COUNT(*)". Count(x) will force array_agg() to
be executed.

Regards,Jeff Davis





pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Variable renaming in AllocSetContextCreate (will commit soon, no functional impact)
Next
From: Jeff Davis
Date:
Subject: Re: Variable renaming in AllocSetContextCreate (will commit soon, no functional impact)