firtst release
Revision | e891d547ad3f37f4ad971a28834a752564765d18 (tree) |
---|---|
Time | 2020-10-29 21:03:05 |
Author | 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 increasing hash_mem_multiplier.
@@ -2777,6 +2777,31 @@ set_join_config_options(unsigned char enforce_mask, GucContext context) | ||
2777 | 2777 | SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP); |
2778 | 2778 | SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN); |
2779 | 2779 | SET_CONFIG_OPTION("enable_hashjoin", ENABLE_HASHJOIN); |
2780 | + | |
2781 | + /* | |
2782 | + * Hash join may be rejected for the reason of estimated memory usage. Try | |
2783 | + * getting rid of that limitation. | |
2784 | + */ | |
2785 | + if (enforce_mask == ENABLE_HASHJOIN) | |
2786 | + { | |
2787 | + char buf[32]; | |
2788 | + int new_multipler; | |
2789 | + | |
2790 | + /* See final_cost_hashjoin(). */ | |
2791 | + new_multipler = MAX_KILOBYTES / work_mem; | |
2792 | + | |
2793 | + /* See guc.c for the upper limit */ | |
2794 | + if (new_multipler >= 1000) | |
2795 | + new_multipler = 1000; | |
2796 | + | |
2797 | + if (new_multipler > hash_mem_multiplier) | |
2798 | + { | |
2799 | + snprintf(buf, sizeof(buf), UINT64_FORMAT, (uint64)new_multipler); | |
2800 | + set_config_option_noerror("hash_mem_multiplier", buf, | |
2801 | + context, PGC_S_SESSION, GUC_ACTION_SAVE, | |
2802 | + true, ERROR); | |
2803 | + } | |
2804 | + } | |
2780 | 2805 | } |
2781 | 2806 | |
2782 | 2807 | /* |