summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-12-30 23:53:15 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-12-30 23:53:15 +0000
commitbe6c38b9033c546e2a8a9fab4329b89be57a263b (patch)
tree521c34b2c94d52614160a5582654751e089b226e /src/backend/optimizer/util
parent5e545151671fa4ab3cf0e62ffd1e207609ad1517 (diff)
Adjust the definition of RestrictInfo's left_relids and right_relids
fields: now they are valid whenever the clause is a binary opclause, not only when it is a potential join clause (there is a new boolean field canjoin to signal the latter condition). This lets us avoid recomputing the relid sets over and over while examining indexes. Still more work to do to make this as useful as it could be, because there are places that could use the info but don't have access to the RestrictInfo node.
Diffstat (limited to 'src/backend/optimizer/util')
-rw-r--r--src/backend/optimizer/util/clauses.c16
-rw-r--r--src/backend/optimizer/util/restrictinfo.c14
2 files changed, 19 insertions, 11 deletions
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index d6f0bb3ad2e..35efa6bc630 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.157 2003/12/28 21:57:37 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.158 2003/12/30 23:53:15 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -812,6 +812,20 @@ is_pseudo_constant_clause(Node *clause)
}
/*
+ * is_pseudo_constant_clause_relids
+ * Same as above, except caller already has available the var membership
+ * of the clause; this lets us avoid the contain_var_clause() scan.
+ */
+bool
+is_pseudo_constant_clause_relids(Node *clause, Relids relids)
+{
+ if (bms_is_empty(relids) &&
+ !contain_volatile_functions(clause))
+ return true;
+ return false;
+}
+
+/*
* pull_constant_clauses
* Scan through a list of qualifications and separate "constant" quals
* from those that are not.
diff --git a/src/backend/optimizer/util/restrictinfo.c b/src/backend/optimizer/util/restrictinfo.c
index 2ae122e92a9..f77966a2262 100644
--- a/src/backend/optimizer/util/restrictinfo.c
+++ b/src/backend/optimizer/util/restrictinfo.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.20 2003/11/29 19:51:51 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.21 2003/12/30 23:53:15 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -227,15 +227,9 @@ join_clause_is_redundant(Query *root,
if (redundant)
{
- /*
- * It looks redundant, now check for "var = const" case. If
- * left_relids/right_relids are set, then there are definitely
- * vars on both sides; else we must check the hard way.
- */
- if (rinfo->left_relids)
- return true; /* var = var, so redundant */
- if (contain_var_clause(get_leftop(rinfo->clause)) &&
- contain_var_clause(get_rightop(rinfo->clause)))
+ /* It looks redundant, but check for "var = const" case */
+ if (!bms_is_empty(rinfo->left_relids) &&
+ !bms_is_empty(rinfo->right_relids))
return true; /* var = var, so redundant */
/* else var = const, not redundant */
}