Heikki Linnakangas <hlinnakan...@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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers