Re: Memory Issue with array_agg? - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Memory Issue with array_agg?
Date
Msg-id CAFj8pRCv57Yo4X5hduG7iGkS7DLCrFBy4KGef_tuX+m69u8_Dg@mail.gmail.com
Whole thread Raw
In response to Memory Issue with array_agg?  (Robert Sosinski <rsosinski@ticketevolution.com>)
Responses Re: Memory Issue with array_agg?  (Robert Sosinski <rsosinski@ticketevolution.com>)
List pgsql-general
Hello

please, can you send some example or test?

Regards

Pavel Stehule


2013/8/19 Robert Sosinski <rsosinski@ticketevolution.com>
When using array_agg on a large table, memory usage seems to spike up until Postgres crashes with the following error:

2013-08-17 18:41:02 UTC [2716]: [2] WARNING: terminating connection because of crash of another server process
2013-08-17 18:41:02 UTC [2716]: [3] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.
2013-08-17 18:41:02 UTC [2716]: [4] HINT: In a moment you should be able to reconnect to the database and repeat your command.


I've definitely isolated it down to using array_agg, as when I changed the query to use string_agg, it worked fine.  I also tried using array_agg on a few different queries, all yielding the same issue.  Swapping in string_agg fixed the issue once more.

This particular table has over 2 million rows and is 1.2 Gigs, and when I ran the query while viewing htop, the virtual size of the Postgres process ballooned to 13.9G until crashing.

The version of Postgres I am using is: PostgreSQL 9.2.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2, 64-bit

Any help would be much appreciated, thanks!

-Robert

pgsql-general by date:

Previous
From: Christoph Moench-Tegeder
Date:
Subject: Re: Memory Issue with array_agg?
Next
From: Vik Fearing
Date:
Subject: Re: Denormalized field