OSDN Git Service

Support "Memoize" Hint.
[pghintplan/pg_hint_plan.git] / expected / ut-J.out
index 1d91c2c..44b724d 100644 (file)
@@ -4717,3 +4717,68 @@ error hint:
          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
 
 \! rm results/ut-J.tmpout
+-- Memoize
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.val = t2.val and t2.id = t3.id;
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t2.id = t3.id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t3.id
+               ->  Seq Scan on t3
+   ->  Memoize
+         Cache Key: t2.val
+         ->  Index Scan using t1_val on t1
+               Index Cond: (val = t2.val)
+(11 rows)
+
+/*+ nomemoize(t1 t2)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.val = t2.val and t2.id = t3.id;  -- doesn't work
+LOG:  pg_hint_plan:
+used hint:
+NoMemoize(t1 t2)
+not used hint:
+duplication hint:
+error hint:
+
+                 QUERY PLAN                 
+--------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t2.id = t3.id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t3.id
+               ->  Seq Scan on t3
+   ->  Memoize
+         Cache Key: t2.val
+         ->  Index Scan using t1_val on t1
+               Index Cond: (val = t2.val)
+(11 rows)
+
+/*+ nomemoize(t1 t2 t3)*/
+EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.val = t2.val and t2.id = t3.id;
+LOG:  pg_hint_plan:
+used hint:
+NoMemoize(t1 t2 t3)
+not used hint:
+duplication hint:
+error hint:
+
+                    QUERY PLAN                    
+--------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.val = t2.val)
+   ->  Index Scan using t1_val on t1
+   ->  Sort
+         Sort Key: t2.val
+         ->  Merge Join
+               Merge Cond: (t2.id = t3.id)
+               ->  Index Scan using t2_pkey on t2
+               ->  Sort
+                     Sort Key: t3.id
+                     ->  Seq Scan on t3
+(11 rows)
+