summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-01-07 22:40:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-01-07 22:40:49 +0000
commit445ce15702f701423a0fed3defe3a43662c7cd8d (patch)
treef2b79c75d8be22098f0f7c093127b133755de22a /src/backend/optimizer
parent12dcf7bb7552386c7a18d8a30b176718eb51c00e (diff)
Create a third option named "partition" for constraint_exclusion, and make it
the default. This setting enables constraint exclusion checks only for appendrel members (ie, inheritance children and UNION ALL arms), which are the cases in which constraint exclusion is most likely to be useful. Avoiding the overhead for simple queries that are unlikely to benefit should bring the cost down to the point where this is a reasonable default setting. Per today's discussion.
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/util/plancat.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 948c0602136..f4f8ac8a763 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.153 2009/01/01 17:23:45 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.154 2009/01/07 22:40:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,7 @@
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
+#include "optimizer/cost.h"
#include "optimizer/plancat.h"
#include "optimizer/predtest.h"
#include "optimizer/prep.h"
@@ -43,7 +44,7 @@
/* GUC parameter */
-bool constraint_exclusion = false;
+int constraint_exclusion = CONSTRAINT_EXCLUSION_PARTITION;
/* Hook for plugins to get control in get_relation_info() */
get_relation_info_hook_type get_relation_info_hook = NULL;
@@ -561,8 +562,9 @@ get_relation_constraints(PlannerInfo *root,
* self-inconsistent restrictions, or restrictions inconsistent with the
* relation's CHECK constraints.
*
- * Note: this examines only rel->relid and rel->baserestrictinfo; therefore
- * it can be called before filling in other fields of the RelOptInfo.
+ * Note: this examines only rel->relid, rel->reloptkind, and
+ * rel->baserestrictinfo; therefore it can be called before filling in
+ * other fields of the RelOptInfo.
*/
bool
relation_excluded_by_constraints(PlannerInfo *root,
@@ -573,8 +575,10 @@ relation_excluded_by_constraints(PlannerInfo *root,
List *safe_constraints;
ListCell *lc;
- /* Skip the test if constraint exclusion is disabled */
- if (!constraint_exclusion)
+ /* Skip the test if constraint exclusion is disabled for the rel */
+ if (constraint_exclusion == CONSTRAINT_EXCLUSION_OFF ||
+ (constraint_exclusion == CONSTRAINT_EXCLUSION_PARTITION &&
+ rel->reloptkind != RELOPT_OTHER_MEMBER_REL))
return false;
/*