• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision375fdd256e264f8c32f9218c18c0f87b4c83bb8c (tree)
Time2018-06-08 14:51:08
AuthorKyotaro Horiguchi <horiguchi.kyotaro@lab....>
CommiterKyotaro Horiguchi

Log Message

Taking in 8b6294c7a5 of core code.

Core's planner gets improved as follows. Took it in.

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

Change Summary

Incremental Difference

--- a/core.c
+++ b/core.c
@@ -14,7 +14,8 @@
1414 * src/backend/optimizer/path/allpaths.c
1515 *
1616 * static functions:
17- * set_plain_rel_pathlist()
17+ * set_plain_rel_pathlist()
18+ * create_plain_partial_paths()
1819 * set_append_rel_pathlist()
1920 * add_paths_to_append_rel()
2021 * generate_mergeappend_paths()
@@ -83,6 +84,26 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
8384
8485
8586 /*
87+ * create_plain_partial_paths
88+ * Build partial access paths for parallel scan of a plain relation
89+ */
90+static void
91+create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
92+{
93+ int parallel_workers;
94+
95+ parallel_workers = compute_parallel_worker(rel, rel->pages, -1);
96+
97+ /* If any limit was set to zero, the user doesn't want a parallel scan. */
98+ if (parallel_workers <= 0)
99+ return;
100+
101+ /* Add an unordered partial path based on a parallel sequential scan. */
102+ add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
103+}
104+
105+
106+/*
86107 * set_append_rel_pathlist
87108 * Build access paths for an "append relation"
88109 */
@@ -195,7 +216,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
195216 build_partitioned_rels = true;
196217 break;
197218 default:
198- elog(ERROR, "unexpcted rtekind: %d", (int) rte->rtekind);
219+ elog(ERROR, "unexpected rtekind: %d", (int) rte->rtekind);
199220 }
200221
201222 /*
@@ -716,25 +737,6 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
716737 return rel;
717738 }
718739
719-/*
720- * create_plain_partial_paths
721- * Build partial access paths for parallel scan of a plain relation
722- */
723-static void
724-create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
725-{
726- int parallel_workers;
727-
728- parallel_workers = compute_parallel_worker(rel, rel->pages, -1);
729-
730- /* If any limit was set to zero, the user doesn't want a parallel scan. */
731- if (parallel_workers <= 0)
732- return;
733-
734- /* Add an unordered partial path based on a parallel sequential scan. */
735- add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
736-}
737-
738740
739741 /*
740742 * join_search_one_level
@@ -1448,18 +1450,21 @@ mark_dummy_rel(RelOptInfo *rel)
14481450
14491451
14501452 /*
1451- * restriction_is_constant_false --- is a restrictlist just FALSE?
1453+ * restriction_is_constant_false --- is a restrictlist just false?
14521454 *
1453- * In cases where a qual is provably constant FALSE, eval_const_expressions
1455+ * In cases where a qual is provably constant false, eval_const_expressions
14541456 * will generally have thrown away anything that's ANDed with it. In outer
14551457 * join situations this will leave us computing cartesian products only to
14561458 * decide there's no match for an outer row, which is pretty stupid. So,
14571459 * we need to detect the case.
14581460 *
1459- * If only_pushed_down is TRUE, then consider only pushed-down quals.
1461+ * If only_pushed_down is true, then consider only quals that are pushed-down
1462+ * from the point of view of the joinrel.
14601463 */
14611464 static bool
1462-restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
1465+restriction_is_constant_false(List *restrictlist,
1466+ RelOptInfo *joinrel,
1467+ bool only_pushed_down)
14631468 {
14641469 ListCell *lc;
14651470
@@ -1473,7 +1478,7 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
14731478 {
14741479 RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);
14751480
1476- if (only_pushed_down && !rinfo->is_pushed_down)
1481+ if (only_pushed_down && !RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
14771482 continue;
14781483
14791484 if (rinfo->clause && IsA(rinfo->clause, Const))
--- a/make_join_rel.c
+++ b/make_join_rel.c
@@ -7,7 +7,7 @@
77 * src/backend/optimizer/path/joinrels.c
88 * make_join_rel()
99 *
10- * Portions Copyright (c) 2013-2017, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
10+ * Portions Copyright (c) 2013-2018, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
1111 * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
1212 * Portions Copyright (c) 1994, Regents of the University of California
1313 *
@@ -255,7 +255,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
255255 {
256256 case JOIN_INNER:
257257 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
258- restriction_is_constant_false(restrictlist, false))
258+ restriction_is_constant_false(restrictlist, joinrel, false))
259259 {
260260 mark_dummy_rel(joinrel);
261261 break;
@@ -269,12 +269,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
269269 break;
270270 case JOIN_LEFT:
271271 if (is_dummy_rel(rel1) ||
272- restriction_is_constant_false(restrictlist, true))
272+ restriction_is_constant_false(restrictlist, joinrel, true))
273273 {
274274 mark_dummy_rel(joinrel);
275275 break;
276276 }
277- if (restriction_is_constant_false(restrictlist, false) &&
277+ if (restriction_is_constant_false(restrictlist, joinrel, false) &&
278278 bms_is_subset(rel2->relids, sjinfo->syn_righthand))
279279 mark_dummy_rel(rel2);
280280 add_paths_to_joinrel(root, joinrel, rel1, rel2,
@@ -286,7 +286,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
286286 break;
287287 case JOIN_FULL:
288288 if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) ||
289- restriction_is_constant_false(restrictlist, true))
289+ restriction_is_constant_false(restrictlist, joinrel, true))
290290 {
291291 mark_dummy_rel(joinrel);
292292 break;
@@ -322,7 +322,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
322322 bms_is_subset(sjinfo->min_righthand, rel2->relids))
323323 {
324324 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
325- restriction_is_constant_false(restrictlist, false))
325+ restriction_is_constant_false(restrictlist, joinrel, false))
326326 {
327327 mark_dummy_rel(joinrel);
328328 break;
@@ -345,7 +345,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
345345 sjinfo) != NULL)
346346 {
347347 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
348- restriction_is_constant_false(restrictlist, false))
348+ restriction_is_constant_false(restrictlist, joinrel, false))
349349 {
350350 mark_dummy_rel(joinrel);
351351 break;
@@ -360,12 +360,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
360360 break;
361361 case JOIN_ANTI:
362362 if (is_dummy_rel(rel1) ||
363- restriction_is_constant_false(restrictlist, true))
363+ restriction_is_constant_false(restrictlist, joinrel, true))
364364 {
365365 mark_dummy_rel(joinrel);
366366 break;
367367 }
368- if (restriction_is_constant_false(restrictlist, false) &&
368+ if (restriction_is_constant_false(restrictlist, joinrel, false) &&
369369 bms_is_subset(rel2->relids, sjinfo->syn_righthand))
370370 mark_dummy_rel(rel2);
371371 add_paths_to_joinrel(root, joinrel, rel1, rel2,
Show on old repository browser