firtst release
Revision | e701eee8123682aae4fec5dc9639b50a54eb0b35 (tree) |
---|---|
Time | 2017-02-16 19:08:54 |
Author | Kyotaro Horiguchi <horiguchi.kyotaro@lab....> |
Commiter | Kyotaro Horiguchi |
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.
@@ -568,13 +568,20 @@ error hint: | ||
568 | 568 | -> Seq Scan on p2_c3_c2 |
569 | 569 | (23 rows) |
570 | 570 | |
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 | + | |
571 | 578 | /*+Parallel(p1 0 hard) IndexScan(p1) */ |
572 | 579 | EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id; |
573 | 580 | LOG: pg_hint_plan: |
574 | 581 | used hint: |
575 | 582 | IndexScan(p1) |
576 | -Parallel(p1 0 hard) | |
577 | 583 | not used hint: |
584 | +Parallel(p1 0 hard) | |
578 | 585 | duplication hint: |
579 | 586 | error hint: |
580 | 587 |
@@ -3089,16 +3089,17 @@ find_parallel_hint(PlannerInfo *root, Index relid) | ||
3089 | 3089 | rel = root->simple_rel_array[relid]; |
3090 | 3090 | |
3091 | 3091 | /* |
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. | |
3098 | 3094 | */ |
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) | |
3102 | 3103 | return NULL; |
3103 | 3104 | |
3104 | 3105 | /* |
@@ -3107,11 +3108,6 @@ find_parallel_hint(PlannerInfo *root, Index relid) | ||
3107 | 3108 | rte = root->simple_rte_array[relid]; |
3108 | 3109 | Assert(rte); |
3109 | 3110 | |
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 | - | |
3115 | 3111 | /* Find parallel method hint, which matches given names, from the list. */ |
3116 | 3112 | for (i = 0; i < current_hint_state->num_hints[HINT_TYPE_PARALLEL]; i++) |
3117 | 3113 | { |
@@ -99,6 +99,9 @@ EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id; | ||
99 | 99 | -- we don't have parallel over index scans so far |
100 | 100 | /*+Parallel(p1 8 hard) IndexScan(p1) */ |
101 | 101 | 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; | |
102 | 105 | /*+Parallel(p1 0 hard) IndexScan(p1) */ |
103 | 106 | EXPLAIN (COSTS false) SELECT * FROM p1 join p2 on p1.id = p2.id; |
104 | 107 |