mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
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.
This commit is contained in:
@@ -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/optimizer/clauses.h,v 1.73 2004/03/14 23:41:27 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/clauses.h,v 1.74 2004/06/11 01:09:12 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -67,6 +67,8 @@ extern void set_coercionform_dontcare(Node *node);
|
||||
|
||||
extern Node *eval_const_expressions(Node *node);
|
||||
|
||||
extern Node *estimate_expression_value(Node *node);
|
||||
|
||||
extern bool expression_tree_walker(Node *node, bool (*walker) (),
|
||||
void *context);
|
||||
extern Node *expression_tree_mutator(Node *node, Node *(*mutator) (),
|
||||
|
||||
@@ -7,18 +7,22 @@
|
||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.28 2003/11/29 22:41:07 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/include/optimizer/planner.h,v 1.29 2004/06/11 01:09:12 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PLANNER_H
|
||||
#define PLANNER_H
|
||||
|
||||
#include "nodes/params.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/plannodes.h"
|
||||
|
||||
|
||||
extern Plan *planner(Query *parse, bool isCursor, int cursorOptions);
|
||||
extern ParamListInfo PlannerBoundParamList; /* current boundParams */
|
||||
|
||||
extern Plan *planner(Query *parse, bool isCursor, int cursorOptions,
|
||||
ParamListInfo boundParams);
|
||||
extern Plan *subquery_planner(Query *parse, double tuple_fraction);
|
||||
|
||||
#endif /* PLANNER_H */
|
||||
|
||||
Reference in New Issue
Block a user