--- /dev/null
+LOAD 'pg_hint_plan';
+SET client_min_messages TO log;
+\set SHOW_CONTEXT always
+SET pg_hint_plan.debug_print TO on;
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+ QUERY PLAN
+--------------------------------------
+ Merge Join
+ Merge Cond: (t1.id = t2.id)
+ -> Index Scan using t1_pkey on t1
+ -> Index Scan using t2_pkey on t2
+(4 rows)
+
+set pg_hint_plan.hints_anywhere = on;
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+LOG: pg_hint_plan:
+used hint:
+HashJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+ QUERY PLAN
+------------------------------
+ Hash Join
+ Hash Cond: (t1.id = t2.id)
+ -> Seq Scan on t1
+ -> Hash
+ -> Seq Scan on t2
+(5 rows)
+
+set pg_hint_plan.hints_anywhere = off;
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+ QUERY PLAN
+--------------------------------------
+ Merge Join
+ Merge Cond: (t1.id = t2.id)
+ -> Index Scan using t1_pkey on t1
+ -> Index Scan using t2_pkey on t2
+(4 rows)
+
+set pg_hint_plan.hints_anywhere = on;
+/*+ MergeJoin(t1 t2) */
+explain (costs false)
+select * from t1 join t2 on t1.val = t2.val where '/*+HashJoin(t1 t2)*/' <> '';
+LOG: pg_hint_plan:
+used hint:
+MergeJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+ QUERY PLAN
+-------------------------------------------
+ Merge Join
+ Merge Cond: (t2.val = t1.val)
+ -> Index Scan using t2_val on t2
+ -> Materialize
+ -> Index Scan using t1_val on t1
+(5 rows)
+
+/*+ HashJoin(t1 t2) */
+explain (costs false)
+select * from t1 join t2 on t1.val = t2.val where '/*+MergeJoin(t1 t2)*/' <> '';
+LOG: pg_hint_plan:
+used hint:
+HashJoin(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+ QUERY PLAN
+--------------------------------
+ Hash Join
+ Hash Cond: (t2.val = t1.val)
+ -> Seq Scan on t2
+ -> Hash
+ -> Seq Scan on t1
+(5 rows)
+
--- /dev/null
+LOAD 'pg_hint_plan';
+SET client_min_messages TO log;
+\set SHOW_CONTEXT always
+SET pg_hint_plan.debug_print TO on;
+
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+
+set pg_hint_plan.hints_anywhere = on;
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+
+set pg_hint_plan.hints_anywhere = off;
+explain (costs false)
+select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
+
+set pg_hint_plan.hints_anywhere = on;
+/*+ MergeJoin(t1 t2) */
+explain (costs false)
+select * from t1 join t2 on t1.val = t2.val where '/*+HashJoin(t1 t2)*/' <> '';
+
+/*+ HashJoin(t1 t2) */
+explain (costs false)
+select * from t1 join t2 on t1.val = t2.val where '/*+MergeJoin(t1 t2)*/' <> '';