diff options
| author | Tom Lane | 2004-06-11 01:09:22 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-06-11 01:09:22 +0000 |
| commit | 7643bed58ecc87eedf7da1ed1938e85ed770d2f8 (patch) | |
| tree | 0d97a4c6cb2d02ba9f9d9b5b5d4e1a6d9cbd538e /src/include/tcop | |
| parent | 5fe8c7d6e50e3a310498f333e4f5130659c931fb (diff) | |
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/include/tcop')
| -rw-r--r-- | src/include/tcop/tcopprot.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 1218e04fdfb..0f55e9787fd 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.66 2004/05/29 22:48:23 tgl Exp $ + * $PostgreSQL: pgsql/src/include/tcop/tcopprot.h,v 1.67 2004/06/11 01:09:22 tgl Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -22,6 +22,7 @@ #include <setjmp.h> #include "executor/execdesc.h" +#include "nodes/params.h" #include "tcop/dest.h" #include "utils/guc.h" @@ -55,8 +56,9 @@ extern List *pg_parse_query(const char *query_string); extern List *pg_analyze_and_rewrite(Node *parsetree, Oid *paramTypes, int numParams); extern List *pg_rewrite_queries(List *querytree_list); -extern Plan *pg_plan_query(Query *querytree); -extern List *pg_plan_queries(List *querytrees, bool needSnapshot); +extern Plan *pg_plan_query(Query *querytree, ParamListInfo boundParams); +extern List *pg_plan_queries(List *querytrees, ParamListInfo boundParams, + bool needSnapshot); extern bool assign_max_stack_depth(int newval, bool doit, GucSource source); |
