firtst release
Revision | 4e6f85c3016d5bb36b541f73dc77cb80143aa4f7 (tree) |
---|---|
Zeit | 2020-10-29 21:09:36 |
Autor | Kyotaro Horiguchi <horikyoga.ntt@gmai...> |
Commiter | 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.
@@ -2775,6 +2775,25 @@ set_join_config_options(unsigned char enforce_mask, GucContext context) | ||
2775 | 2775 | SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP); |
2776 | 2776 | SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN); |
2777 | 2777 | SET_CONFIG_OPTION("enable_hashjoin", ENABLE_HASHJOIN); |
2778 | + | |
2779 | + /* | |
2780 | + * Hash join may be rejected for the reason of estimated memory usage. Try | |
2781 | + * getting rid of that limitation. This change on work_mem is reverted just | |
2782 | + * after searching join path so no suginificant side-effects are expected. | |
2783 | + */ | |
2784 | + if (enforce_mask == ENABLE_HASHJOIN) | |
2785 | + { | |
2786 | + char buf[32]; | |
2787 | + | |
2788 | + /* See final_cost_hashjoin(). */ | |
2789 | + if (work_mem < MAX_KILOBYTES) | |
2790 | + { | |
2791 | + snprintf(buf, sizeof(buf), UINT64_FORMAT, (uint64)MAX_KILOBYTES); | |
2792 | + set_config_option_noerror("work_mem", buf, | |
2793 | + context, PGC_S_SESSION, GUC_ACTION_SAVE, | |
2794 | + true, ERROR); | |
2795 | + } | |
2796 | + } | |
2778 | 2797 | } |
2779 | 2798 | |
2780 | 2799 | /* |