(4 rows)
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
- QUERY PLAN
---------------------------------
- Hash Join
- Hash Cond: (t2.val = t1.val)
+ QUERY PLAN
+-------------------------------------------
+ Nested Loop
-> Seq Scan on t2
- -> Hash
- -> Seq Scan on t1
-(5 rows)
+ -> Memoize
+ Cache Key: t2.val
+ -> Index Scan using t1_val on t1
+ Index Cond: (val = t2.val)
+(6 rows)
LOAD 'pg_hint_plan';
SET pg_hint_plan.debug_print TO on;
(4 rows)
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
- QUERY PLAN
---------------------------------
- Hash Join
- Hash Cond: (t2.val = t1.val)
+ QUERY PLAN
+-------------------------------------------
+ Nested Loop
-> Seq Scan on t2
- -> Hash
- -> Seq Scan on t1
-(5 rows)
+ -> Memoize
+ Cache Key: t2.val
+ -> Index Scan using t1_val on t1
+ Index Cond: (val = t2.val)
+(6 rows)
/*+ Test (t1 t2) */
EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
Index Cond: (id = $1)
(51 rows)
--- ambigous error
+-- ambiguous error
EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
- QUERY PLAN
--------------------------------------------------
- Merge Join
- Merge Cond: (t1.id = t2.id)
- -> Merge Join
- Merge Cond: (t1.id = t1_1.id)
+ QUERY PLAN
+--------------------------------------------
+ Nested Loop
+ -> Nested Loop
+ -> Seq Scan on t1 t1_1
-> Index Scan using t1_pkey on t1
- -> Index Scan using t1_pkey on t1 t1_1
+ Index Cond: (id = t1_1.id)
-> Index Scan using t2_pkey on t2
+ Index Cond: (id = t1.id)
(7 rows)
-/*+NestLoop(t1 t2)*/
+/*+MergeJoin(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
-INFO: pg_hint_plan: hint syntax error at or near "NestLoop(t1 t2)"
+INFO: pg_hint_plan: hint syntax error at or near "MergeJoin(t1 t2)"
DETAIL: Relation name "t1" is ambiguous.
LOG: pg_hint_plan:
used hint:
not used hint:
duplication hint:
error hint:
-NestLoop(t1 t2)
+MergeJoin(t1 t2)
- QUERY PLAN
--------------------------------------------------
- Merge Join
- Merge Cond: (t1.id = t2.id)
- -> Merge Join
- Merge Cond: (t1.id = t1_1.id)
+ QUERY PLAN
+--------------------------------------------
+ Nested Loop
+ -> Nested Loop
+ -> Seq Scan on t1 t1_1
-> Index Scan using t1_pkey on t1
- -> Index Scan using t1_pkey on t1 t1_1
+ Index Cond: (id = t1_1.id)
-> Index Scan using t2_pkey on t2
+ Index Cond: (id = t1.id)
(7 rows)
/*+Leading(t1 t2 t1)*/
error hint:
Leading(t1 t2 t1)
- QUERY PLAN
--------------------------------------------------
- Merge Join
- Merge Cond: (t1.id = t2.id)
- -> Merge Join
- Merge Cond: (t1.id = t1_1.id)
+ QUERY PLAN
+--------------------------------------------
+ Nested Loop
+ -> Nested Loop
+ -> Seq Scan on t1 t1_1
-> Index Scan using t1_pkey on t1
- -> Index Scan using t1_pkey on t1 t1_1
+ Index Cond: (id = t1_1.id)
-> Index Scan using t2_pkey on t2
+ Index Cond: (id = t1.id)
(7 rows)
-- identifier length test
duplication hint:
error hint:
-CONTEXT: SQL statement "SELECT 1, /*+ SeqScan(t1) */ * from t1"
+CONTEXT: SQL statement "SELECT 1, /*+ SeqScan(t1) */ * from t1"
PL/pgSQL function testfunc() line 3 at PERFORM
testfunc
----------