]> granicus.if.org Git - postgresql/commit
When using extended-query protocol, postpone planning of unnamed statements
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Jun 2004 01:09:22 +0000 (01:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 11 Jun 2004 01:09:22 +0000 (01:09 +0000)
commit7643bed58ecc87eedf7da1ed1938e85ed770d2f8
tree0d97a4c6cb2d02ba9f9d9b5b5d4e1a6d9cbd538e
parent5fe8c7d6e50e3a310498f333e4f5130659c931fb
When using extended-query protocol, postpone planning of unnamed statements
until Bind is received, so that actual parameter values are visible to the
planner.  Make use of the parameter values for estimation purposes (but
don't fold them into the actual plan).  This buys back most of the
potential loss of plan quality that ensues from using out-of-line
parameters instead of putting literal values right into the query text.

This patch creates a notion of constant-folding expressions 'for
estimation purposes only', in which case we can be more aggressive than
the normal eval_const_expressions() logic can be.  Right now the only
difference in behavior is inserting bound values for Params, but it will
be interesting to look at other possibilities.  One that we've seen
come up repeatedly is reducing now() and related functions to current
values, so that queries like ... WHERE timestampcol > now() - '1 day'
have some chance of being planned effectively.

Oliver Jowett, with some kibitzing from Tom Lane.
14 files changed:
doc/src/sgml/protocol.sgml
src/backend/commands/explain.c
src/backend/commands/portalcmds.c
src/backend/commands/prepare.c
src/backend/executor/functions.c
src/backend/executor/spi.c
src/backend/optimizer/path/clausesel.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/util/clauses.c
src/backend/tcop/postgres.c
src/backend/utils/adt/selfuncs.c
src/include/optimizer/clauses.h
src/include/optimizer/planner.h
src/include/tcop/tcopprot.h