pgsql: Redesign the plancache mechanism for more flexibility and effici

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Redesign the plancache mechanism for more flexibility and effici
Date: 2011-09-16 04:44:41
Message-ID: E1R4QI5-0000Bh-RS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Redesign the plancache mechanism for more flexibility and efficiency.

Rewrite plancache.c so that a "cached plan" (which is rather a misnomer
at this point) can support generation of custom, parameter-value-dependent
plans, and can make an intelligent choice between using custom plans and
the traditional generic-plan approach. The specific choice algorithm
implemented here can probably be improved in future, but this commit is
all about getting the mechanism in place, not the policy.

In addition, restructure the API to greatly reduce the amount of extraneous
data copying needed. The main compromise needed to make that possible was
to split the initial creation of a CachedPlanSource into two steps. It's
worth noting in particular that SPI_saveplan is now deprecated in favor of
SPI_keepplan, which accomplishes the same end result with zero data
copying, and no need to then spend even more cycles throwing away the
original SPIPlan. The risk of long-term memory leaks while manipulating
SPIPlans has also been greatly reduced. Most of this improvement is based
on use of the recently-added MemoryContextSetParent primitive.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/e6faf910d75027bdce7cd0f2033db4e912592bcc

Modified Files
--------------
contrib/spi/refint.c | 14 +-
contrib/spi/timetravel.c | 7 +-
doc/src/sgml/plpgsql.sgml | 119 ++--
doc/src/sgml/protocol.sgml | 50 +-
doc/src/sgml/ref/prepare.sgml | 44 +-
doc/src/sgml/spi.sgml | 237 ++++--
src/backend/catalog/namespace.c | 18 +
src/backend/commands/prepare.c | 144 ++--
src/backend/executor/spi.c | 363 ++++-----
src/backend/tcop/postgres.c | 226 ++----
src/backend/utils/adt/ri_triggers.c | 4 +-
src/backend/utils/adt/ruleutils.c | 6 +-
src/backend/utils/cache/plancache.c | 1521 +++++++++++++++++++++++------------
src/backend/utils/mmgr/mcxt.c | 12 +
src/backend/utils/mmgr/portalmem.c | 6 +-
src/include/catalog/namespace.h | 1 +
src/include/commands/prepare.h | 8 +-
src/include/executor/spi.h | 1 +
src/include/executor/spi_priv.h | 41 +-
src/include/nodes/parsenodes.h | 3 +
src/include/utils/memutils.h | 1 +
src/include/utils/plancache.h | 156 +++--
src/pl/plperl/plperl.c | 18 +-
src/pl/plpgsql/src/pl_exec.c | 215 ++++--
src/pl/plpython/plpython.c | 11 +-
src/pl/tcl/pltcl.c | 17 +-
src/test/regress/regress.c | 5 +-
27 files changed, 1909 insertions(+), 1339 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-09-16 08:29:14 pgsql: gistendscan() forgot to free so->giststate.
Previous Message Robert Haas 2011-09-15 12:03:09 Re: Use of literal in SGML docs