BUG #5608: array_agg() consumes too much memory - Mailing list pgsql-bugs

From Itagaki Takahiro
Subject BUG #5608: array_agg() consumes too much memory
Date
Msg-id 201008090941.o799fCCF057912@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5608: array_agg() consumes too much memory  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5608
Logged by:          Itagaki Takahiro
Email address:      itagaki.takahiro@gmail.com
PostgreSQL version: 9.0beta4
Operating system:   Windows 7 (32bit)
Description:        array_agg() consumes too much memory
Details:

I encountered "out of memory" error in large
GROUP BY query with array_agg(). The server log
was filled by the following messages:

    accumArrayResult: 8192 total in 1 blocks; 7800 free (0 chunks); 392
used

Should we choose smaller size of initial memory in accumArrayResult()?
It allocates ALLOCSET_DEFAULT_INITSIZE (=8kB) now,
but only 10% of the area was used in my case.

Note that work_mem is not considered in the case;
array_agg() allocates 8kB * (number of groups).

pgsql-bugs by date:

Previous
From: Patric de Waha
Date:
Subject: Automated analyze process fails with custom function, which works perfect as regular user (8.4.2).
Next
From: Heikki Linnakangas
Date:
Subject: Assertion failure with assignment to array elem