• R/O
  • R/O (HTTP)
  • R/W (SSH)
  • R/W (HTTPS)

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revisione701eee8123682aae4fec5dc9639b50a54eb0b35 (tree)
Time2017-02-16 19:08:54
AuthorKyotaro Horiguchi <horiguchi.kyotaro@lab....>
CommiterKyotaro Horiguchi

Log Message

Don't apply parallel hint on rels that planner considers unsafe.

pg_hint_plan considered had its own decision logic on whether
parallel-safe or not but it is dangerous and unnecessary. Just follow
planner's decision.

Change Summary

Incremental Difference

--- a/expected/ut-W.out
+++ b/expected/ut-W.out
@@ -568,13 +568,20 @@ error hint:
568568 -> Seq Scan on p2_c3_c2
569569 (23 rows)
570570
571+-- This hint doesn't turn on parallel, so the Parallel hint is ignored
572+show max_parallel_workers_per_gather;
573+ max_parallel_workers_per_gather
574+---------------------------------
575+ 0
576+(1 row)
577+
571578 /*+Parallel(p1 0 hard) IndexScan(p1) */
572579 EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id;
573580 LOG: pg_hint_plan:
574581 used hint:
575582 IndexScan(p1)
576-Parallel(p1 0 hard)
577583 not used hint:
584+Parallel(p1 0 hard)
578585 duplication hint:
579586 error hint:
580587
--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -3089,16 +3089,17 @@ find_parallel_hint(PlannerInfo *root, Index relid)
30893089 rel = root->simple_rel_array[relid];
30903090
30913091 /*
3092- * This function is called for any RelOptInfo or its inheritance parent if
3093- * any. If we are called from inheritance planner, the RelOptInfo for the
3094- * parent of target child relation is not set in the planner info.
3095- *
3096- * Otherwise we should check that the reloptinfo is base relation or
3097- * inheritance children.
3092+ * Parallel planning is appliable only on base relation, which has
3093+ * RelOptInfo.
30983094 */
3099- if (rel &&
3100- rel->reloptkind != RELOPT_BASEREL &&
3101- rel->reloptkind != RELOPT_OTHER_MEMBER_REL)
3095+ if (!rel)
3096+ return NULL;
3097+
3098+ /*
3099+ * We have set root->glob->parallelModeOK if needed. What we should do here
3100+ * is just following the decision of planner.
3101+ */
3102+ if (!rel->consider_parallel)
31023103 return NULL;
31033104
31043105 /*
@@ -3107,11 +3108,6 @@ find_parallel_hint(PlannerInfo *root, Index relid)
31073108 rte = root->simple_rte_array[relid];
31083109 Assert(rte);
31093110
3110- /* We don't hint on other than relation and foreign tables */
3111- if (rte->rtekind != RTE_RELATION ||
3112- rte->relkind == RELKIND_FOREIGN_TABLE)
3113- return NULL;
3114-
31153111 /* Find parallel method hint, which matches given names, from the list. */
31163112 for (i = 0; i < current_hint_state->num_hints[HINT_TYPE_PARALLEL]; i++)
31173113 {
--- a/sql/ut-W.sql
+++ b/sql/ut-W.sql
@@ -99,6 +99,9 @@ EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id;
9999 -- we don't have parallel over index scans so far
100100 /*+Parallel(p1 8 hard) IndexScan(p1) */
101101 EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id;
102+
103+-- This hint doesn't turn on parallel, so the Parallel hint is ignored
104+show max_parallel_workers_per_gather;
102105 /*+Parallel(p1 0 hard) IndexScan(p1) */
103106 EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id;
104107
Show on old repository browser