firtst release
Revision | 375fdd256e264f8c32f9218c18c0f87b4c83bb8c (tree) |
---|---|
Time | 2018-06-08 14:51:08 |
Author | Kyotaro Horiguchi <horiguchi.kyotaro@lab....> |
Commiter | Kyotaro Horiguchi |
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.
@@ -14,7 +14,8 @@ | ||
14 | 14 | * src/backend/optimizer/path/allpaths.c |
15 | 15 | * |
16 | 16 | * static functions: |
17 | - * set_plain_rel_pathlist() | |
17 | + * set_plain_rel_pathlist() | |
18 | + * create_plain_partial_paths() | |
18 | 19 | * set_append_rel_pathlist() |
19 | 20 | * add_paths_to_append_rel() |
20 | 21 | * generate_mergeappend_paths() |
@@ -83,6 +84,26 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte) | ||
83 | 84 | |
84 | 85 | |
85 | 86 | /* |
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 | +/* | |
86 | 107 | * set_append_rel_pathlist |
87 | 108 | * Build access paths for an "append relation" |
88 | 109 | */ |
@@ -195,7 +216,7 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel, | ||
195 | 216 | build_partitioned_rels = true; |
196 | 217 | break; |
197 | 218 | default: |
198 | - elog(ERROR, "unexpcted rtekind: %d", (int) rte->rtekind); | |
219 | + elog(ERROR, "unexpected rtekind: %d", (int) rte->rtekind); | |
199 | 220 | } |
200 | 221 | |
201 | 222 | /* |
@@ -716,25 +737,6 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels) | ||
716 | 737 | return rel; |
717 | 738 | } |
718 | 739 | |
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 | - | |
738 | 740 | |
739 | 741 | /* |
740 | 742 | * join_search_one_level |
@@ -1448,18 +1450,21 @@ mark_dummy_rel(RelOptInfo *rel) | ||
1448 | 1450 | |
1449 | 1451 | |
1450 | 1452 | /* |
1451 | - * restriction_is_constant_false --- is a restrictlist just FALSE? | |
1453 | + * restriction_is_constant_false --- is a restrictlist just false? | |
1452 | 1454 | * |
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 | |
1454 | 1456 | * will generally have thrown away anything that's ANDed with it. In outer |
1455 | 1457 | * join situations this will leave us computing cartesian products only to |
1456 | 1458 | * decide there's no match for an outer row, which is pretty stupid. So, |
1457 | 1459 | * we need to detect the case. |
1458 | 1460 | * |
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. | |
1460 | 1463 | */ |
1461 | 1464 | 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) | |
1463 | 1468 | { |
1464 | 1469 | ListCell *lc; |
1465 | 1470 |
@@ -1473,7 +1478,7 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down) | ||
1473 | 1478 | { |
1474 | 1479 | RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc); |
1475 | 1480 | |
1476 | - if (only_pushed_down && !rinfo->is_pushed_down) | |
1481 | + if (only_pushed_down && !RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids)) | |
1477 | 1482 | continue; |
1478 | 1483 | |
1479 | 1484 | if (rinfo->clause && IsA(rinfo->clause, Const)) |
@@ -7,7 +7,7 @@ | ||
7 | 7 | * src/backend/optimizer/path/joinrels.c |
8 | 8 | * make_join_rel() |
9 | 9 | * |
10 | - * Portions Copyright (c) 2013-2017, NIPPON TELEGRAPH AND TELEPHONE CORPORATION | |
10 | + * Portions Copyright (c) 2013-2018, NIPPON TELEGRAPH AND TELEPHONE CORPORATION | |
11 | 11 | * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group |
12 | 12 | * Portions Copyright (c) 1994, Regents of the University of California |
13 | 13 | * |
@@ -255,7 +255,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
255 | 255 | { |
256 | 256 | case JOIN_INNER: |
257 | 257 | if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || |
258 | - restriction_is_constant_false(restrictlist, false)) | |
258 | + restriction_is_constant_false(restrictlist, joinrel, false)) | |
259 | 259 | { |
260 | 260 | mark_dummy_rel(joinrel); |
261 | 261 | break; |
@@ -269,12 +269,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
269 | 269 | break; |
270 | 270 | case JOIN_LEFT: |
271 | 271 | if (is_dummy_rel(rel1) || |
272 | - restriction_is_constant_false(restrictlist, true)) | |
272 | + restriction_is_constant_false(restrictlist, joinrel, true)) | |
273 | 273 | { |
274 | 274 | mark_dummy_rel(joinrel); |
275 | 275 | break; |
276 | 276 | } |
277 | - if (restriction_is_constant_false(restrictlist, false) && | |
277 | + if (restriction_is_constant_false(restrictlist, joinrel, false) && | |
278 | 278 | bms_is_subset(rel2->relids, sjinfo->syn_righthand)) |
279 | 279 | mark_dummy_rel(rel2); |
280 | 280 | add_paths_to_joinrel(root, joinrel, rel1, rel2, |
@@ -286,7 +286,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
286 | 286 | break; |
287 | 287 | case JOIN_FULL: |
288 | 288 | if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) || |
289 | - restriction_is_constant_false(restrictlist, true)) | |
289 | + restriction_is_constant_false(restrictlist, joinrel, true)) | |
290 | 290 | { |
291 | 291 | mark_dummy_rel(joinrel); |
292 | 292 | break; |
@@ -322,7 +322,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
322 | 322 | bms_is_subset(sjinfo->min_righthand, rel2->relids)) |
323 | 323 | { |
324 | 324 | if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || |
325 | - restriction_is_constant_false(restrictlist, false)) | |
325 | + restriction_is_constant_false(restrictlist, joinrel, false)) | |
326 | 326 | { |
327 | 327 | mark_dummy_rel(joinrel); |
328 | 328 | break; |
@@ -345,7 +345,7 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
345 | 345 | sjinfo) != NULL) |
346 | 346 | { |
347 | 347 | if (is_dummy_rel(rel1) || is_dummy_rel(rel2) || |
348 | - restriction_is_constant_false(restrictlist, false)) | |
348 | + restriction_is_constant_false(restrictlist, joinrel, false)) | |
349 | 349 | { |
350 | 350 | mark_dummy_rel(joinrel); |
351 | 351 | break; |
@@ -360,12 +360,12 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1, | ||
360 | 360 | break; |
361 | 361 | case JOIN_ANTI: |
362 | 362 | if (is_dummy_rel(rel1) || |
363 | - restriction_is_constant_false(restrictlist, true)) | |
363 | + restriction_is_constant_false(restrictlist, joinrel, true)) | |
364 | 364 | { |
365 | 365 | mark_dummy_rel(joinrel); |
366 | 366 | break; |
367 | 367 | } |
368 | - if (restriction_is_constant_false(restrictlist, false) && | |
368 | + if (restriction_is_constant_false(restrictlist, joinrel, false) && | |
369 | 369 | bms_is_subset(rel2->relids, sjinfo->syn_righthand)) |
370 | 370 | mark_dummy_rel(rel2); |
371 | 371 | add_paths_to_joinrel(root, joinrel, rel1, rel2, |