• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: コミット

firtst release


コミットメタ情報

リビジョン1935002bc6e7b1a0590dcd318363429636d608aa (tree)
日時2018-06-08 14:48:36
作者Kyotaro Horiguchi <horiguchi.kyotaro@lab....>
コミッターKyotaro Horiguchi

ログメッセージ

Took in core improvement.

Took in the following commit of core. A minor non-functional fix was
made on the way.

64ad85860c Change more places to be less trusting of RestrictInfo.is_pushed_down.

Fixed typos and removed useless include on the way.

変更サマリ

差分

--- 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 * generate_mergeappend_paths()
2021 * get_cheapest_parameterized_child_path()
@@ -43,7 +44,7 @@
4344 * restriction_is_constant_false()
4445 *
4546 *
46- * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
47+ * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
4748 * Portions Copyright (c) 1994, Regents of the University of California
4849 *
4950 *-------------------------------------------------------------------------
@@ -81,6 +82,67 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
8182 }
8283
8384 /*
85+ * create_plain_partial_paths
86+ * Build partial access paths for parallel scan of a plain relation
87+ */
88+static void
89+create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
90+{
91+ int parallel_workers;
92+
93+ /*
94+ * If the user has set the parallel_workers reloption, use that; otherwise
95+ * select a default number of workers.
96+ */
97+ if (rel->rel_parallel_workers != -1)
98+ parallel_workers = rel->rel_parallel_workers;
99+ else
100+ {
101+ int parallel_threshold;
102+
103+ /*
104+ * If this relation is too small to be worth a parallel scan, just
105+ * return without doing anything ... unless it's an inheritance child.
106+ * In that case, we want to generate a parallel path here anyway. It
107+ * might not be worthwhile just for this relation, but when combined
108+ * with all of its inheritance siblings it may well pay off.
109+ */
110+ if (rel->pages < (BlockNumber) min_parallel_relation_size &&
111+ rel->reloptkind == RELOPT_BASEREL)
112+ return;
113+
114+ /*
115+ * Select the number of workers based on the log of the size of the
116+ * relation. This probably needs to be a good deal more
117+ * sophisticated, but we need something here for now. Note that the
118+ * upper limit of the min_parallel_relation_size GUC is chosen to
119+ * prevent overflow here.
120+ */
121+ parallel_workers = 1;
122+ parallel_threshold = Max(min_parallel_relation_size, 1);
123+ while (rel->pages >= (BlockNumber) (parallel_threshold * 3))
124+ {
125+ parallel_workers++;
126+ parallel_threshold *= 3;
127+ if (parallel_threshold > INT_MAX / 3)
128+ break; /* avoid overflow */
129+ }
130+ }
131+
132+ /*
133+ * In no case use more than max_parallel_workers_per_gather workers.
134+ */
135+ parallel_workers = Min(parallel_workers, max_parallel_workers_per_gather);
136+
137+ /* If any limit was set to zero, the user doesn't want a parallel scan. */
138+ if (parallel_workers <= 0)
139+ return;
140+
141+ /* Add an unordered partial path based on a parallel sequential scan. */
142+ add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
143+}
144+
145+/*
84146 * set_append_rel_pathlist
85147 * Build access paths for an "append relation"
86148 */
@@ -629,67 +691,6 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
629691 }
630692
631693 /*
632- * create_plain_partial_paths
633- * Build partial access paths for parallel scan of a plain relation
634- */
635-static void
636-create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
637-{
638- int parallel_workers;
639-
640- /*
641- * If the user has set the parallel_workers reloption, use that; otherwise
642- * select a default number of workers.
643- */
644- if (rel->rel_parallel_workers != -1)
645- parallel_workers = rel->rel_parallel_workers;
646- else
647- {
648- int parallel_threshold;
649-
650- /*
651- * If this relation is too small to be worth a parallel scan, just
652- * return without doing anything ... unless it's an inheritance child.
653- * In that case, we want to generate a parallel path here anyway. It
654- * might not be worthwhile just for this relation, but when combined
655- * with all of its inheritance siblings it may well pay off.
656- */
657- if (rel->pages < (BlockNumber) min_parallel_relation_size &&
658- rel->reloptkind == RELOPT_BASEREL)
659- return;
660-
661- /*
662- * Select the number of workers based on the log of the size of the
663- * relation. This probably needs to be a good deal more
664- * sophisticated, but we need something here for now. Note that the
665- * upper limit of the min_parallel_relation_size GUC is chosen to
666- * prevent overflow here.
667- */
668- parallel_workers = 1;
669- parallel_threshold = Max(min_parallel_relation_size, 1);
670- while (rel->pages >= (BlockNumber) (parallel_threshold * 3))
671- {
672- parallel_workers++;
673- parallel_threshold *= 3;
674- if (parallel_threshold > INT_MAX / 3)
675- break; /* avoid overflow */
676- }
677- }
678-
679- /*
680- * In no case use more than max_parallel_workers_per_gather workers.
681- */
682- parallel_workers = Min(parallel_workers, max_parallel_workers_per_gather);
683-
684- /* If any limit was set to zero, the user doesn't want a parallel scan. */
685- if (parallel_workers <= 0)
686- return;
687-
688- /* Add an unordered partial path based on a parallel sequential scan. */
689- add_partial_path(rel, create_seqscan_path(root, rel, NULL, parallel_workers));
690-}
691-
692-/*
693694 * join_search_one_level
694695 * Consider ways to produce join relations containing exactly 'level'
695696 * jointree items. (This is one step of the dynamic-programming method
@@ -1394,18 +1395,21 @@ mark_dummy_rel(RelOptInfo *rel)
13941395 }
13951396
13961397 /*
1397- * restriction_is_constant_false --- is a restrictlist just FALSE?
1398+ * restriction_is_constant_false --- is a restrictlist just false?
13981399 *
1399- * In cases where a qual is provably constant FALSE, eval_const_expressions
1400+ * In cases where a qual is provably constant false, eval_const_expressions
14001401 * will generally have thrown away anything that's ANDed with it. In outer
14011402 * join situations this will leave us computing cartesian products only to
14021403 * decide there's no match for an outer row, which is pretty stupid. So,
14031404 * we need to detect the case.
14041405 *
1405- * If only_pushed_down is TRUE, then consider only pushed-down quals.
1406+ * If only_pushed_down is true, then consider only quals that are pushed-down
1407+ * from the point of view of the joinrel.
14061408 */
14071409 static bool
1408-restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
1410+restriction_is_constant_false(List *restrictlist,
1411+ RelOptInfo *joinrel,
1412+ bool only_pushed_down)
14091413 {
14101414 ListCell *lc;
14111415
@@ -1420,7 +1424,7 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
14201424 RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
14211425
14221426 Assert(IsA(rinfo, RestrictInfo));
1423- if (only_pushed_down && !rinfo->is_pushed_down)
1427+ if (only_pushed_down && !RINFO_IS_PUSHED_DOWN(rinfo, joinrel->relids))
14241428 continue;
14251429
14261430 if (rinfo->clause && IsA(rinfo->clause, Const))
--- a/make_join_rel.c
+++ b/make_join_rel.c
@@ -7,8 +7,8 @@
77 * src/backend/optimizer/path/joinrels.c
88 * make_join_rel()
99 *
10- * Portions Copyright (c) 2013-2017, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
11- * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
10+ * Portions Copyright (c) 2013-2018, NIPPON TELEGRAPH AND TELEPHONE CORPORATION
11+ * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
1212 * Portions Copyright (c) 1994, Regents of the University of California
1313 *
1414 *-------------------------------------------------------------------------
@@ -230,7 +230,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
230230 {
231231 case JOIN_INNER:
232232 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
233- restriction_is_constant_false(restrictlist, false))
233+ restriction_is_constant_false(restrictlist, joinrel, false))
234234 {
235235 mark_dummy_rel(joinrel);
236236 break;
@@ -244,12 +244,12 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
244244 break;
245245 case JOIN_LEFT:
246246 if (is_dummy_rel(rel1) ||
247- restriction_is_constant_false(restrictlist, true))
247+ restriction_is_constant_false(restrictlist, joinrel, true))
248248 {
249249 mark_dummy_rel(joinrel);
250250 break;
251251 }
252- if (restriction_is_constant_false(restrictlist, false) &&
252+ if (restriction_is_constant_false(restrictlist, joinrel, false) &&
253253 bms_is_subset(rel2->relids, sjinfo->syn_righthand))
254254 mark_dummy_rel(rel2);
255255 add_paths_to_joinrel(root, joinrel, rel1, rel2,
@@ -261,7 +261,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
261261 break;
262262 case JOIN_FULL:
263263 if ((is_dummy_rel(rel1) && is_dummy_rel(rel2)) ||
264- restriction_is_constant_false(restrictlist, true))
264+ restriction_is_constant_false(restrictlist, joinrel, true))
265265 {
266266 mark_dummy_rel(joinrel);
267267 break;
@@ -297,7 +297,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
297297 bms_is_subset(sjinfo->min_righthand, rel2->relids))
298298 {
299299 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
300- restriction_is_constant_false(restrictlist, false))
300+ restriction_is_constant_false(restrictlist, joinrel, false))
301301 {
302302 mark_dummy_rel(joinrel);
303303 break;
@@ -320,7 +320,7 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
320320 sjinfo) != NULL)
321321 {
322322 if (is_dummy_rel(rel1) || is_dummy_rel(rel2) ||
323- restriction_is_constant_false(restrictlist, false))
323+ restriction_is_constant_false(restrictlist, joinrel, false))
324324 {
325325 mark_dummy_rel(joinrel);
326326 break;
@@ -335,12 +335,12 @@ make_join_rel(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2)
335335 break;
336336 case JOIN_ANTI:
337337 if (is_dummy_rel(rel1) ||
338- restriction_is_constant_false(restrictlist, true))
338+ restriction_is_constant_false(restrictlist, joinrel, true))
339339 {
340340 mark_dummy_rel(joinrel);
341341 break;
342342 }
343- if (restriction_is_constant_false(restrictlist, false) &&
343+ if (restriction_is_constant_false(restrictlist, joinrel, false) &&
344344 bms_is_subset(rel2->relids, sjinfo->syn_righthand))
345345 mark_dummy_rel(rel2);
346346 add_paths_to_joinrel(root, joinrel, rel1, rel2,
--- a/pg_stat_statements.c
+++ b/pg_stat_statements.c
@@ -2,7 +2,7 @@
22 *
33 * pg_stat_statements.c
44 *
5- * Part of pg_stat_statements.c in PostgreSQL 9.5.
5+ * Part of pg_stat_statements.c in PostgreSQL 9.6.
66 *
77 * Copyright (c) 2008-2016, PostgreSQL Global Development Group
88 *
@@ -10,8 +10,6 @@
1010 */
1111 #include "postgres.h"
1212
13-#include <sys/stat.h>
14-
1513 #include "access/hash.h"
1614 #include "parser/scanner.h"
1715
旧リポジトリブラウザで表示