Re: OOM on EXPLAIN with lots of nodes

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: OOM on EXPLAIN with lots of nodes
Дата
Msg-id 11105.1421162380@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: OOM on EXPLAIN with lots of nodes  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Ответы Re: OOM on EXPLAIN with lots of nodes  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Heikki Linnakangas <hlinnakangas@vmware.com> writes:
> On 01/13/2015 02:08 PM, Alexey Bashtanov wrote:
>> By varying the parameters and reading source code I determined that
>> memory usage linearly depends on (plan nodes count)*(overall columns
>> count), thus it quadratically depends on number of tables unionized.
>> 
>> To remove this excessive memory usage I propose
>> to run deparse_context_for_planstate+deparse_expression in a separate
>> memory context and free it after a plan node is generated.

> Hmm, something like the attached? Seems reasonable...

This looks pretty unsafe to me: it assumes, without much justification,
that there is no memory allocated during show_expression() that will be
needed later.

I suspect the O(N^2) consumption comes directly from some workspace
allocated for variable deparsing in ruleutils.c.  A safer fix would
be to do retail pfrees on that.
        regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Safe memory allocation functions
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [BUGS] BUG #12070: hstore extension: hstore_to_json_loose produces invalid JSON