• R/O
  • HTTP
  • SSH
  • HTTPS

pg_hint_plan: Commit

firtst release


Commit MetaInfo

Revision4e6f85c3016d5bb36b541f73dc77cb80143aa4f7 (tree)
Zeit2020-10-29 21:09:36
AutorKyotaro 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 temporarily increasing work_mem. This change affects
only join-searching so no significant side-effects are expected.

Ändern Zusammenfassung

Diff

--- a/pg_hint_plan.c
+++ b/pg_hint_plan.c
@@ -2775,6 +2775,25 @@ set_join_config_options(unsigned char enforce_mask, GucContext context)
27752775 SET_CONFIG_OPTION("enable_nestloop", ENABLE_NESTLOOP);
27762776 SET_CONFIG_OPTION("enable_mergejoin", ENABLE_MERGEJOIN);
27772777 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+ }
27782797 }
27792798
27802799 /*
Show on old repository browser