Re: Parallel Aggregates for string_agg and array_agg

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Parallel Aggregates for string_agg and array_agg
Дата
Msg-id CAKJS1f8==VFrSkNEpFj4bTuOte=ijG8tdxcvnOEy+DGNLN+gLA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Parallel Aggregates for string_agg and array_agg  ("Tels" <nospam-pg-abuse@bloodgate.com>)
Список pgsql-hackers
Thanks for your input on all this. It's good to some words from people
using the software rather than just writing it.

On 6 April 2018 at 07:10, Tels <nospam-pg-abuse@bloodgate.com> wrote:
> PS: We use string_agg() in a case where we first agg each row, then
> string_agg() all rows, and the resulting string is really huge. We did run
> into the "out of memory"-problem, so we now use a LIMIT and assembly the
> resulting parts on the client side. My wish here would be to better know
> how large the LIMIT can be, I found it quite difficult to predict with how
> many rows PG runs out of memory for the string buffer, even tho all rows
> have almost the same length as text. But that aside, getting the parts
> faster with parallel agg would be very cool, too.

For this problem, if you're getting "Cannot enlarge string buffer
containing X bytes by Y more bytes.", then you're not actually hitting
an OOM error, it's more the required string length is above
MaxAllocSize, which as mentioned by Tomas is 1GB.

See enlargeStringInfo() in stringinfo.c

if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("out of memory"),
errdetail("Cannot enlarge string buffer containing %d bytes by %d more bytes.",
   str->len, needed)));

Allocating chunks in smaller increments won't help if you're getting this.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Magnus Hagander
Дата:
Сообщение: Re: Online enabling of checksums
Следующее
От: Andrew Gierth
Дата:
Сообщение: Checkpoint not retrying failed fsync?