summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2010-03-28 22:59:34 +0000
committerTom Lane2010-03-28 22:59:34 +0000
commitb78f6264eba33e2966447572b8261e353df01e59 (patch)
tree1b5cfa84c32c6683851d335cfa9cd7dab54ecee5 /src/include
parenta760893dbda9934e287789d54bbd3c4ca3914ce0 (diff)
Rework join-removal logic as per recent discussion. In particular this
fixes things so that it works for cases where nested removals are possible. The overhead of the optimization should be significantly less, as well.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/relation.h25
-rw-r--r--src/include/optimizer/pathnode.h4
-rw-r--r--src/include/optimizer/placeholder.h3
-rw-r--r--src/include/optimizer/planmain.h7
5 files changed, 16 insertions, 26 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index e1da4954390..401b69e0883 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.233 2010/01/05 21:53:59 rhaas Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.234 2010/03/28 22:59:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -217,7 +217,6 @@ typedef enum NodeTag
T_ResultPath,
T_MaterialPath,
T_UniquePath,
- T_NoOpPath,
T_EquivalenceClass,
T_EquivalenceMember,
T_PathKey,
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
index 888005282aa..45cb17c52b8 100644
--- a/src/include/nodes/relation.h
+++ b/src/include/nodes/relation.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.184 2010/02/26 02:01:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.185 2010/03/28 22:59:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -240,7 +240,9 @@ typedef struct PlannerInfo
*
* We also have "other rels", which are like base rels in that they refer to
* single RT indexes; but they are not part of the join tree, and are given
- * a different RelOptKind to identify them.
+ * a different RelOptKind to identify them. Lastly, there is a RelOptKind
+ * for "dead" relations, which are base rels that we have proven we don't
+ * need to join after all.
*
* Currently the only kind of otherrels are those made for member relations
* of an "append relation", that is an inheritance set or UNION ALL subquery.
@@ -346,7 +348,8 @@ typedef enum RelOptKind
{
RELOPT_BASEREL,
RELOPT_JOINREL,
- RELOPT_OTHER_MEMBER_REL
+ RELOPT_OTHER_MEMBER_REL,
+ RELOPT_DEADREL
} RelOptKind;
typedef struct RelOptInfo
@@ -802,22 +805,6 @@ typedef struct UniquePath
} UniquePath;
/*
- * NoOpPath represents exactly the same plan as its subpath. This is used
- * when we have determined that a join can be eliminated. The difference
- * between the NoOpPath and its subpath is just that the NoOpPath's parent
- * is the whole join relation while the subpath is for one of the joined
- * relations (and the other one isn't needed).
- *
- * Note: path.pathtype is always T_Join, but this won't actually give rise
- * to a Join plan node.
- */
-typedef struct NoOpPath
-{
- Path path;
- Path *subpath;
-} NoOpPath;
-
-/*
* All join-type paths share these fields.
*/
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index 2255f147bd7..9ff5d6328de 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.83 2010/02/26 02:01:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/pathnode.h,v 1.84 2010/03/28 22:59:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,8 +51,6 @@ extern ResultPath *create_result_path(List *quals);
extern MaterialPath *create_material_path(RelOptInfo *rel, Path *subpath);
extern UniquePath *create_unique_path(PlannerInfo *root, RelOptInfo *rel,
Path *subpath, SpecialJoinInfo *sjinfo);
-extern NoOpPath *create_noop_path(PlannerInfo *root, RelOptInfo *rel,
- Path *subpath);
extern Path *create_subqueryscan_path(RelOptInfo *rel, List *pathkeys);
extern Path *create_functionscan_path(PlannerInfo *root, RelOptInfo *rel);
extern Path *create_valuesscan_path(PlannerInfo *root, RelOptInfo *rel);
diff --git a/src/include/optimizer/placeholder.h b/src/include/optimizer/placeholder.h
index c23d1b5cd15..e9dde9315e3 100644
--- a/src/include/optimizer/placeholder.h
+++ b/src/include/optimizer/placeholder.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/placeholder.h,v 1.4 2010/01/02 16:58:07 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/placeholder.h,v 1.5 2010/03/28 22:59:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,6 +22,7 @@ extern PlaceHolderVar *make_placeholder_expr(PlannerInfo *root, Expr *expr,
extern PlaceHolderInfo *find_placeholder_info(PlannerInfo *root,
PlaceHolderVar *phv);
extern void fix_placeholder_eval_levels(PlannerInfo *root);
+extern void add_placeholders_to_base_rels(PlannerInfo *root);
extern void add_placeholders_to_joinrel(PlannerInfo *root,
RelOptInfo *joinrel);
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 62742f57792..416cec0d4e7 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.126 2010/02/26 02:01:26 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/planmain.h,v 1.127 2010/03/28 22:59:33 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -109,6 +109,11 @@ extern RestrictInfo *build_implied_join_equality(Oid opno,
Relids qualscope);
/*
+ * prototypes for plan/analyzejoins.c
+ */
+extern List *remove_useless_joins(PlannerInfo *root, List *joinlist);
+
+/*
* prototypes for plan/setrefs.c
*/
extern Plan *set_plan_references(PlannerGlobal *glob,