firtst release
リビジョン | 0fe27602c9c1f41e066901c20800fdec6f9ac184 (tree) |
---|---|
日時 | 2020-10-29 21:12:16 |
作者 | Kyotaro Horiguchi <horikyoga.ntt@gmai...> |
コミッター | Kyotaro Horiguchi |
Make HashJoin hint more coercive.
Even with HashJoin hint, hash joins may be rejected by planner if hash
table for the inner-rel is estimated too large. Make HashJoin hint
more coercive by temporarily increasing work_mem. This change affects
only join-searching so no significant side-effects are expected.
@@ -2770,6 +2770,25 @@ set_join_config_options(unsigned char enforce_mask, GucContext context) | ||
2770 | 2770 | SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP); |
2771 | 2771 | SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN); |
2772 | 2772 | SET_CONFIG_OPTION("enable_hashjoin", ENABLE_HASHJOIN); |
2773 | + | |
2774 | + /* | |
2775 | + * Hash join may be rejected for the reason of estimated memory usage. Try | |
2776 | + * getting rid of that limitation. This change on work_mem is reverted just | |
2777 | + * after searching join path so no suginificant side-effects are expected. | |
2778 | + */ | |
2779 | + if (enforce_mask == ENABLE_HASHJOIN) | |
2780 | + { | |
2781 | + char buf[32]; | |
2782 | + | |
2783 | + /* See final_cost_hashjoin(). */ | |
2784 | + if (work_mem < MAX_KILOBYTES) | |
2785 | + { | |
2786 | + snprintf(buf, sizeof(buf), UINT64_FORMAT, (uint64)MAX_KILOBYTES); | |
2787 | + set_config_option_noerror("work_mem", buf, | |
2788 | + context, PGC_S_SESSION, GUC_ACTION_SAVE, | |
2789 | + true, ERROR); | |
2790 | + } | |
2791 | + } | |
2773 | 2792 | } |
2774 | 2793 | |
2775 | 2794 | /* |