OSDN Git Service

Reduce memory consumption inside inheritance_planner().
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 Dec 2010 20:10:28 +0000 (15:10 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 5 Dec 2010 20:10:28 +0000 (15:10 -0500)
commitd1001a78ce612a16ea622b558f5fc2b68c45ab4c
tree6551ba8b2acf703d3af33faba167b3ee79e5eec2
parentd1f5a92e18dcfc750e9d338597e66af920aad99e
Reduce memory consumption inside inheritance_planner().

Avoid eating quite so much memory for large inheritance trees, by
reclaiming the space used by temporary copies of the original parsetree and
range table, as well as the workspace needed during planning.  The cost is
needing to copy the finished plan trees out of the child memory context.
Although this looks like it ought to slow things down, my testing shows
it actually is faster, apparently because fewer interactions with malloc()
are needed and/or we can do the work within a more readily cacheable amount
of memory.  That result might be platform-dependent, but I'll take it.

Per a gripe from John Papandriopoulos, in which it was pointed out that the
memory consumption actually grew as O(N^2) for sufficiently many child
tables, since we were creating N copies of the N-element range table.
src/backend/optimizer/plan/planner.c