diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-06-11 01:09:22 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-06-11 01:09:22 +0000 |
commit | 7643bed58ecc87eedf7da1ed1938e85ed770d2f8 (patch) | |
tree | 0d97a4c6cb2d02ba9f9d9b5b5d4e1a6d9cbd538e /src/backend/executor | |
parent | 5fe8c7d6e50e3a310498f333e4f5130659c931fb (diff) | |
download | postgresql-7643bed58ecc87eedf7da1ed1938e85ed770d2f8.tar.gz postgresql-7643bed58ecc87eedf7da1ed1938e85ed770d2f8.zip |
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.
Diffstat (limited to 'src/backend/executor')
-rw-r--r-- | src/backend/executor/functions.c | 4 | ||||
-rw-r--r-- | src/backend/executor/spi.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 2e75813a2ab..9ddf6192775 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.81 2004/05/26 04:41:15 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.82 2004/06/11 01:08:42 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ init_execution_state(List *queryTree_list) Plan *planTree; execution_state *newes; - planTree = pg_plan_query(queryTree); + planTree = pg_plan_query(queryTree, NULL); newes = (execution_state *) palloc(sizeof(execution_state)); if (preves) diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index f5f2850b982..91b633d9bd8 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.117 2004/06/06 00:41:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.118 2004/06/11 01:08:43 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1125,7 +1125,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan) QueryDesc *qdesc; DestReceiver *dest; - planTree = pg_plan_query(queryTree); + planTree = pg_plan_query(queryTree, NULL); plan_list = lappend(plan_list, planTree); dest = CreateDestReceiver(queryTree->canSetTag ? SPI : None, NULL); |