WIP: Add support for copying node tree into single allocation.
As an example as to why one would want that, here's a
MemoryContextStats for the same query being added to the
plancache. The query is just a randomly selected one among the queries
issued by \d+.
PREPARE foo AS SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, false AS relhasoids, c.relispartition, pg_catalog.array_to_string(c.reloptions || array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', '), c.reltablespace, CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, c.relpersistence, c.relreplident, am.amname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid) LEFT JOIN pg_catalog.pg_am am ON (c.relam = am.oid) WHERE c.oid = '1259';
EXECUTE foo ;
With single-allocation:
CachedPlan: 24504 total in 2 blocks; 664 free (0 chunks); 23840 used
Grand total: 24504 bytes in 2 blocks; 664 free (0 chunks); 23840 used
Default:
CachedPlan: 65536 total in 7 blocks; 16016 free (0 chunks); 49520 used
Grand total: 65536 bytes in 7 blocks; 16016 free (0 chunks); 49520 used
Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch: