OSDN Git Service

Taking in 8b6294c7a5 of core code.
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 8 Jun 2018 02:54:28 +0000 (11:54 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 8 Jun 2018 05:51:08 +0000 (14:51 +0900)
Core's planner gets improved as follows. Took it in.

8b6294c7a5 Change more places to be less trusting of RestrictInfo.is_pushed_down.

core.c
make_join_rel.c

diff --git a/core.c b/core.c
index b36cdd8..4ca915d 100644 (file)
--- a/core.c
+++ b/core.c
@@ -14,7 +14,8 @@
  * src/backend/optimizer/path/allpaths.c
  *
  *     static functions:
- *        set_plain_rel_pathlist()
+ *     set_plain_rel_pathlist()
+ *     create_plain_partial_paths()
  *     set_append_rel_pathlist()
  *     add_paths_to_append_rel()
  *     generate_mergeappend_paths()
@@ -83,6 +84,26 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
 
 
 /*
+ * create_plain_partial_paths
+ *       Build partial access paths for parallel scan of a plain relation
+ */
+static void
+create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
+{
+       int                     parallel_workers;
+
+       parallel_workers = compute_parallel_worker(rel, rel->pages, -1);
+
+       /* If any limit was set to zero, the user doesn't want a parallel scan. */
+       if (parallel_workers <= 0)
+               return;
+
+       /* Add an unordered partial path based on a parallel sequential scan. */
+       add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
+}
+
+
+/*
  * set_append_rel_pathlist
  *       Build access paths for an "append relation"
  */
@@ -195,7 +216,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
                        build_partitioned_rels = true;
                        break;
                default:
-                       elog(ERROR, "unexpcted rtekind: %d", (int) rte->rtekind);
+                       elog(ERROR, "unexpected rtekind: %d", (int) rte->rtekind);
        }
 
        /*
@@ -716,25 +737,6 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
        return rel;
 }
 
-/*
- * create_plain_partial_paths
- *       Build partial access paths for parallel scan of a plain relation
- */
-static void
-create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
-{
-       int                     parallel_workers;
-
-       parallel_workers = compute_parallel_worker(rel, rel->pages, -1);
-
-       /* If any limit was set to zero, the user doesn't want a parallel scan. */
-       if (parallel_workers <= 0)
-               return;
-
-       /* Add an unordered partial path based on a parallel sequential scan. */
-       add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
-}
-
 
 /*
  * join_search_one_level
@@ -1448,18 +1450,21 @@ mark_dummy_rel(RelOptInfo *rel)
 
 
 /*
- * restriction_is_constant_false --- is a restrictlist just FALSE?
+ * restriction_is_constant_false --- is a restrictlist just false?
  *
- * In cases where a qual is provably constant FALSE, eval_const_expressions
+ * In cases where a qual is provably constant false, eval_const_expressions
  * will generally have thrown away anything that's ANDed with it.  In outer
  * join situations this will leave us computing cartesian products only to
  * decide there's no match for an outer row, which is pretty stupid.  So,
  * we need to detect the case.
  *
- * If only_pushed_down is TRUE, then consider only pushed-down quals.
+ * If only_pushed_down is true, then consider only quals that are pushed-down
+ * from the point of view of the joinrel.
  */
 static bool
-restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
+restriction_is_constant_false(List *restrictlist,
+                                                         RelOptInfo *joinrel,
+                                                         bool only_pushed_down)
 {
        ListCell   *lc;
 
@@ -1473,7 +1478,7 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
        {
                RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
 
-               if (only_pushed_down && !rinfo->is_pushed_down)
+               if (only_pushed_down && !RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
                        continue;
 
                if (rinfo->clause && IsA(rinfo->clause, Const))
index d57b6da..3763bf4 100644 (file)
@@ -7,7 +7,7 @@
  * src/backend/optimizer/path/joinrels.c
  *     make_join_rel()
  *
- * Portions Copyright (c) 2013-2017, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
+ * Portions Copyright (c) 2013-2018, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
@@ -255,7 +255,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
        {
                case JOIN_INNER:
                        if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                               restriction_is_constant_false(restrictlist, false))
+                               restriction_is_constant_false(restrictlist, joinrel, false))
                        {
                                mark_dummy_rel(joinrel);
                                break;
@@ -269,12 +269,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_LEFT:
                        if (is_dummy_rel(rel1) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
                        }
-                       if (restriction_is_constant_false(restrictlist, false) &&
+                       if (restriction_is_constant_false(restrictlist, joinrel, false) &&
                                bms_is_subset(rel2->relids, sjinfo->syn_righthand))
                                mark_dummy_rel(rel2);
                        add_paths_to_joinrel(root, joinrel, rel1, rel2,
@@ -286,7 +286,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_FULL:
                        if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
@@ -322,7 +322,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                                bms_is_subset(sjinfo->min_righthand, rel2->relids))
                        {
                                if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                                       restriction_is_constant_false(restrictlist, false))
+                                       restriction_is_constant_false(restrictlist, joinrel, false))
                                {
                                        mark_dummy_rel(joinrel);
                                        break;
@@ -345,7 +345,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                                                                   sjinfo) != NULL)
                        {
                                if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
-                                       restriction_is_constant_false(restrictlist, false))
+                                       restriction_is_constant_false(restrictlist, joinrel, false))
                                {
                                        mark_dummy_rel(joinrel);
                                        break;
@@ -360,12 +360,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
                        break;
                case JOIN_ANTI:
                        if (is_dummy_rel(rel1) ||
-                               restriction_is_constant_false(restrictlist, true))
+                               restriction_is_constant_false(restrictlist, joinrel, true))
                        {
                                mark_dummy_rel(joinrel);
                                break;
                        }
-                       if (restriction_is_constant_false(restrictlist, false) &&
+                       if (restriction_is_constant_false(restrictlist, joinrel, false) &&
                                bms_is_subset(rel2->relids, sjinfo->syn_righthand))
                                mark_dummy_rel(rel2);
                        add_paths_to_joinrel(root, joinrel, rel1, rel2,