• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revisione891d547ad3f37f4ad971a28834a752564765d18 (tree)
Time2020-10-29 21:03:05
AuthorKyotaro Horiguchi <horikyoga.ntt@gmai...>
CommiterKyotaro Horiguchi

Log Message

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.

Change Summary

Incremental Difference

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -2777,6 +2777,31 @@ set_join_config_options(unsigned char enforce_mask, GucContext context)
27772777 SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP);
27782778 SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN);
27792779 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+ }
27802805 }
27812806
27822807 /*
Show on old repository browser