OSDN Git Service

Support PostgreSQL 13.
[pghintplan/pg_hint_plan.git] / expected / ut-R.out
index a268d6d..eed3fe3 100644 (file)
@@ -516,16 +516,16 @@ EXPLAIN SELECT * FROM s1.p1 t1, s1.p1 t2 WHERE t1.c1 = t2.c1;
  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
    Hash Cond: (t1.c1 = t2.c1)
    ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-         ->  Seq Scan on p1 t1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p1c1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
-         ->  Seq Scan on p1c2 t1_2  (cost=xxx..xxx rows=100 width=xxx)
-         ->  Seq Scan on p1c3 t1_3  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1 t1_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p1c1 t1_2  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1c2 t1_3  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1c3 t1_4  (cost=xxx..xxx rows=100 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1 t2  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1 t2_1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2 t2_2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3 t2_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 t2_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 t2_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 t2_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 t2_4  (cost=xxx..xxx rows=100 width=xxx)
 
 \o results/ut-R.tmpout
 /*+Rows(t1 t2 #1)*/
@@ -544,16 +544,16 @@ error hint:
  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
    Hash Cond: (t1.c1 = t2.c1)
    ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-         ->  Seq Scan on p1 t1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p1c1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
-         ->  Seq Scan on p1c2 t1_2  (cost=xxx..xxx rows=100 width=xxx)
-         ->  Seq Scan on p1c3 t1_3  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1 t1_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p1c1 t1_2  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1c2 t1_3  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Seq Scan on p1c3 t1_4  (cost=xxx..xxx rows=100 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1 t2  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1 t2_1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2 t2_2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3 t2_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 t2_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 t2_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 t2_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 t2_4  (cost=xxx..xxx rows=100 width=xxx)
 
 -- No. R-1-6-3
 \o results/ut-R.tmpout
@@ -747,20 +747,18 @@ error hint:
 EXPLAIN WITH c1(c1) AS (SELECT max(t1.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1) SELECT * FROM s1.t1, c1 WHERE t1.c1 = c1.c1;
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                            QUERY PLAN                                            
---------------------------------------------------------------------------------------------------
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-                 Merge Cond: (t1_1.c1 = t2.c1)
-                 ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
-                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                       Sort Key: t2.c1
-                       ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
-   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+   ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
+               Merge Cond: (t1_1.c1 = t2.c1)
+               ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
+               ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                     Sort Key: t2.c1
+                     ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
-         Index Cond: (c1 = c1.c1)
+         Index Cond: (c1 = (max(t1_1.c1)))
 
 \o results/ut-R.tmpout
 /*+Rows(t1 t2 #1)Rows(t1 c1 +1)*/
@@ -775,20 +773,18 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                            QUERY PLAN                                            
---------------------------------------------------------------------------------------------------
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                 Merge Cond: (t1_1.c1 = t2.c1)
-                 ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
-                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                       Sort Key: t2.c1
-                       ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
-   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+   ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+               Merge Cond: (t1_1.c1 = t2.c1)
+               ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
+               ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                     Sort Key: t2.c1
+                     ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
-         Index Cond: (c1 = c1.c1)
+         Index Cond: (c1 = (max(t1_1.c1)))
 
 -- No. R-1-6-10
 \o results/ut-R.tmpout
@@ -2019,38 +2015,9 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                     QUERY PLAN                                                     
---------------------------------------------------------------------------------------------------------------------
+                                                                               QUERY PLAN                                                                               
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                 Join Filter: (b1t2.c1 = b1t1.c1)
-                 ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                       Hash Cond: (b1t4.c1 = b1t2.c1)
-                       ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-                                   Merge Cond: (b1t3.c1 = b1t2.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                         Sort Key: b1t2.c1
-                                         ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b1t3.c1)
-   CTE c2
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
-                       Hash Cond: (b2t3.c1 = b2t1.c1)
-                       ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
-                             Merge Cond: (b2t3.c1 = b2t4.c1)
-                             ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
-                             ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
-                             ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
-                 ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b2t1.c1)
    ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
          Hash Cond: (bmt4.c1 = bmt1.c1)
          ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
@@ -2062,17 +2029,42 @@ error hint:
                            Sort Key: bmt1.c1
                            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
                                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                                       Hash Cond: (bmt1.c1 = c1.c1)
+                                       Hash Cond: (bmt1.c1 = (max(b1t1.c1)))
                                        ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
                                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                                   Merge Cond: (c1.c1 = c2.c1)
+                                                   Merge Cond: ((max(b1t1.c1)) = (max(b2t1.c1)))
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c1.c1
-                                                         ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b1t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     Join Filter: (b1t2.c1 = b1t1.c1)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
+                                                                           Hash Cond: (b1t4.c1 = b1t2.c1)
+                                                                           ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                 ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                       Merge Cond: (b1t3.c1 = b1t2.c1)
+                                                                                       ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                       ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                             Sort Key: b1t2.c1
+                                                                                             ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b1t3.c1)
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c2.c1
-                                                         ->  CTE Scan on c2  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b2t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                           Hash Cond: (b2t3.c1 = b2t1.c1)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 Merge Cond: (b2t3.c1 = b2t4.c1)
+                                                                                 ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                                 ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                     ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b2t1.c1)
                                  ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
                                        Index Cond: (c1 = bmt1.c1)
 
@@ -2133,38 +2125,9 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                     QUERY PLAN                                                     
---------------------------------------------------------------------------------------------------------------------
+                                                                               QUERY PLAN                                                                               
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                 Join Filter: (b1t2.c1 = b1t1.c1)
-                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Hash Cond: (b1t4.c1 = b1t2.c1)
-                       ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                   Merge Cond: (b1t3.c1 = b1t2.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                         Sort Key: b1t2.c1
-                                         ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b1t3.c1)
-   CTE c2
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Hash Cond: (b2t1.c1 = b2t3.c1)
-                       ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                   Merge Cond: (b2t3.c1 = b2t4.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
-                 ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b2t1.c1)
    ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
          Hash Cond: (bmt4.c1 = bmt1.c1)
          ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
@@ -2176,17 +2139,42 @@ error hint:
                            Sort Key: bmt1.c1
                            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
                                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                                       Hash Cond: (bmt1.c1 = c1.c1)
+                                       Hash Cond: (bmt1.c1 = (max(b1t1.c1)))
                                        ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
                                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                                   Merge Cond: (c1.c1 = c2.c1)
+                                                   Merge Cond: ((max(b1t1.c1)) = (max(b2t1.c1)))
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c1.c1
-                                                         ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b1t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     Join Filter: (b1t2.c1 = b1t1.c1)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Hash Cond: (b1t4.c1 = b1t2.c1)
+                                                                           ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                 ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                       Merge Cond: (b1t3.c1 = b1t2.c1)
+                                                                                       ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                       ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                             Sort Key: b1t2.c1
+                                                                                             ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b1t3.c1)
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c2.c1
-                                                         ->  CTE Scan on c2  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b2t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Hash Cond: (b2t1.c1 = b2t3.c1)
+                                                                           ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                 ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                       Merge Cond: (b2t3.c1 = b2t4.c1)
+                                                                                       ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                       ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                     ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b2t1.c1)
                                  ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
                                        Index Cond: (c1 = bmt1.c1)
 
@@ -2245,51 +2233,9 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                     QUERY PLAN                                                     
---------------------------------------------------------------------------------------------------------------------
+                                                                            QUERY PLAN                                                                            
+------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                 Join Filter: (b1t2.c1 = b1t1.c1)
-                 ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                       Hash Cond: (b1t4.c1 = b1t2.c1)
-                       ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-                                   Merge Cond: (b1t3.c1 = b1t2.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                         Sort Key: b1t2.c1
-                                         ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b1t3.c1)
-   CTE c2
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
-                       Hash Cond: (b2t3.c1 = b2t1.c1)
-                       ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
-                             Merge Cond: (b2t3.c1 = b2t4.c1)
-                             ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
-                             ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
-                             ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
-                 ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b2t1.c1)
-   CTE c3
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                       Hash Cond: (b3t1.c1 = b3t2.c1)
-                       ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
-                             Merge Cond: (b3t1.c1 = b3t4.c1)
-                             ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
-                             ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                             ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b3t1.c1)
    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
                Hash Cond: (bmt3.c1 = bmt1.c1)
@@ -2300,21 +2246,57 @@ error hint:
                            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
                                  Sort Key: bmt1.c1
                                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                                       Join Filter: (c1.c1 = bmt1.c1)
+                                       Join Filter: ((max(b1t1.c1)) = bmt1.c1)
                                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                                             Hash Cond: (c2.c1 = c1.c1)
+                                             Hash Cond: ((max(b2t1.c1)) = (max(b1t1.c1)))
                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                                   Merge Cond: (c2.c1 = c3.c1)
+                                                   Merge Cond: ((max(b2t1.c1)) = (max(b3t1.c1)))
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c2.c1
-                                                         ->  CTE Scan on c2  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b2t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                           Hash Cond: (b2t3.c1 = b2t1.c1)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 Merge Cond: (b2t3.c1 = b2t4.c1)
+                                                                                 ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                                 ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                     ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b2t1.c1)
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c3.c1
-                                                         ->  CTE Scan on c3  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b3t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
+                                                                           Hash Cond: (b3t1.c1 = b3t2.c1)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                                 Merge Cond: (b3t1.c1 = b3t4.c1)
+                                                                                 ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                                 ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                 ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b3t1.c1)
                                              ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                                                   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+                                                   ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                         ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                                               Join Filter: (b1t2.c1 = b1t1.c1)
+                                                               ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     Hash Cond: (b1t4.c1 = b1t2.c1)
+                                                                     ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                     ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                 Merge Cond: (b1t3.c1 = b1t2.c1)
+                                                                                 ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                       Sort Key: b1t2.c1
+                                                                                       ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                               ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     Index Cond: (c1 = b1t3.c1)
                                        ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
-                                             Index Cond: (c1 = c2.c1)
+                                             Index Cond: (c1 = (max(b2t1.c1)))
                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                                  Sort Key: bmt2.c1
                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
@@ -2394,51 +2376,9 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                     QUERY PLAN                                                     
---------------------------------------------------------------------------------------------------------------------
+                                                                               QUERY PLAN                                                                               
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                 Join Filter: (b1t2.c1 = b1t1.c1)
-                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Hash Cond: (b1t4.c1 = b1t2.c1)
-                       ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                   Merge Cond: (b1t3.c1 = b1t2.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                         Sort Key: b1t2.c1
-                                         ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b1t3.c1)
-   CTE c2
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Hash Cond: (b2t1.c1 = b2t3.c1)
-                       ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                             ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                   Merge Cond: (b2t3.c1 = b2t4.c1)
-                                   ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
-                 ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b2t1.c1)
-   CTE c3
-     ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
-           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Hash Cond: (b3t1.c1 = b3t2.c1)
-                       ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                             Merge Cond: (b3t1.c1 = b3t4.c1)
-                             ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
-                             ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                             ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
-                 ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
-                       Index Cond: (c1 = b3t1.c1)
    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
                Hash Cond: (bmt3.c1 = bmt1.c1)
@@ -2449,21 +2389,57 @@ error hint:
                            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
                                  Sort Key: bmt1.c1
                                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                                       Join Filter: (c1.c1 = bmt1.c1)
+                                       Join Filter: ((max(b1t1.c1)) = bmt1.c1)
                                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                                             Hash Cond: (c2.c1 = c1.c1)
+                                             Hash Cond: ((max(b2t1.c1)) = (max(b1t1.c1)))
                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                                   Merge Cond: (c2.c1 = c3.c1)
+                                                   Merge Cond: ((max(b2t1.c1)) = (max(b3t1.c1)))
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c2.c1
-                                                         ->  CTE Scan on c2  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b2t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Hash Cond: (b2t1.c1 = b2t3.c1)
+                                                                           ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                 ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                       Merge Cond: (b2t3.c1 = b2t4.c1)
+                                                                                       ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                       ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                     ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b2t1.c1)
                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                                         Sort Key: c3.c1
-                                                         ->  CTE Scan on c3  (cost=xxx..xxx rows=1 width=xxx)
+                                                         Sort Key: (max(b3t1.c1))
+                                                         ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                               ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Hash Cond: (b3t1.c1 = b3t2.c1)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                 Merge Cond: (b3t1.c1 = b3t4.c1)
+                                                                                 ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
+                                                                                 ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                           ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                 ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                                     ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           Index Cond: (c1 = b3t1.c1)
                                              ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                                                   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+                                                   ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
+                                                         ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                                               Join Filter: (b1t2.c1 = b1t1.c1)
+                                                               ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     Hash Cond: (b1t4.c1 = b1t2.c1)
+                                                                     ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                     ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
+                                                                           ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                                                                 Merge Cond: (b1t3.c1 = b1t2.c1)
+                                                                                 ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                                                                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                                                                                       Sort Key: b1t2.c1
+                                                                                       ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                                               ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                                                     Index Cond: (c1 = b1t3.c1)
                                        ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
-                                             Index Cond: (c1 = c2.c1)
+                                             Index Cond: (c1 = (max(b2t1.c1)))
                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                                  Sort Key: bmt2.c1
                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
@@ -2492,8 +2468,8 @@ SELECT b3t1.c1 FROM s1.t1 b3t1 WHERE b3t1.c1 = 1
 );
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt1)
 not used hint:
+Leading(c1 bmt1)
 duplication hint:
 error hint:
 
@@ -2502,20 +2478,17 @@ error hint:
                                     QUERY PLAN                                    
 ----------------------------------------------------------------------------------
  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-           Index Cond: (c1 = 1)
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
          Index Cond: (c1 = 1)
-         Filter: (c1 <> $2)
-   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
-         Filter: (c1 = 1)
+         Filter: (c1 <> $1)
+   ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = 1)
 
 \o results/ut-R.tmpout
 /*+
@@ -2539,12 +2512,12 @@ SELECT b3t1.c1 FROM s1.t1 b3t1 WHERE b3t1.c1 = 1
 );
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt1)
-Rows(bmt1 c1 #1)
 not used hint:
+Leading(c1 bmt1)
 Rows(b1t1 c1 #1)
 Rows(b2t1 c1 #1)
 Rows(b3t1 c1 #1)
+Rows(bmt1 c1 #1)
 duplication hint:
 error hint:
 
@@ -2553,20 +2526,17 @@ error hint:
                                     QUERY PLAN                                    
 ----------------------------------------------------------------------------------
  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-   CTE c1
-     ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-           Index Cond: (c1 = 1)
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
          Index Cond: (c1 = 1)
-         Filter: (c1 <> $2)
-   ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
-         Filter: (c1 = 1)
+         Filter: (c1 <> $1)
+   ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = 1)
 
 -- No. R-2-2-2
 \o results/ut-R.tmpout
@@ -2598,54 +2568,48 @@ used hint:
 MergeJoin(b1t1 b1t2)
 MergeJoin(b2t1 b2t2)
 MergeJoin(b3t1 b3t2)
-MergeJoin(bmt2 c1)
-HashJoin(bmt1 bmt2 c1)
-Leading(c1 bmt2 bmt1)
 Leading(b1t2 b1t1)
 Leading(b2t2 b2t1)
 Leading(b3t2 b3t1)
 not used hint:
+MergeJoin(bmt2 c1)
+HashJoin(bmt1 bmt2 c1)
+Leading(c1 bmt2 bmt1)
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                         QUERY PLAN                                         
---------------------------------------------------------------------------------------------
- Hash Join  (cost=xxx..xxx rows=10 width=xxx)
-   Hash Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-           Merge Cond: (b1t1.c1 = b1t2.c1)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
-           ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                 Sort Key: b1t2.c1
-                 ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-   InitPlan 2 (returns $1)
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt2.c1)
+   InitPlan 1 (returns $0)
      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
            Merge Cond: (b2t1.c1 = b2t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                  Sort Key: b2t2.c1
                  ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=100 width=xxx)
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
            Merge Cond: (b3t1.c1 = b3t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                  Sort Key: b3t2.c1
                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
-   ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $2)
-   ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+   ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
          ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-               Merge Cond: (bmt2.c1 = c1.c1)
-               ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                     Sort Key: bmt2.c1
-                     ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
+               Merge Cond: (b1t1.c1 = b1t2.c1)
+               ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                     Sort Key: c1.c1
-                     ->  CTE Scan on c1  (cost=xxx..xxx rows=100 width=xxx)
+                     Sort Key: b1t2.c1
+                     ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t1.c1)
+               Filter: (c1 <> $1)
+   ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = b1t1.c1)
 
 \o results/ut-R.tmpout
 /*+
@@ -2682,59 +2646,53 @@ used hint:
 MergeJoin(b1t1 b1t2)
 MergeJoin(b2t1 b2t2)
 MergeJoin(b3t1 b3t2)
-MergeJoin(bmt2 c1)
-HashJoin(bmt1 bmt2 c1)
-Leading(c1 bmt2 bmt1)
 Leading(b1t2 b1t1)
 Leading(b2t2 b2t1)
 Leading(b3t2 b3t1)
 Rows(b1t1 b1t2 #1)
 Rows(b2t1 b2t2 #1)
 Rows(b3t1 b3t2 #1)
+not used hint:
+MergeJoin(bmt2 c1)
+HashJoin(bmt1 bmt2 c1)
+Leading(c1 bmt2 bmt1)
 Rows(bmt2 c1 #1)
 Rows(bmt1 bmt2 c1 #1)
-not used hint:
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                         QUERY PLAN                                         
---------------------------------------------------------------------------------------------
- Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-   Hash Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-           Merge Cond: (b1t1.c1 = b1t2.c1)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
-           ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                 Sort Key: b1t2.c1
-                 ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-   InitPlan 2 (returns $1)
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt2.c1)
+   InitPlan 1 (returns $0)
      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
            Merge Cond: (b2t1.c1 = b2t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                  Sort Key: b2t2.c1
                  ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=100 width=xxx)
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
            Merge Cond: (b3t1.c1 = b3t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
                  Sort Key: b3t2.c1
                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
-   ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $2)
-   ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
+   ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
          ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-               Merge Cond: (bmt2.c1 = c1.c1)
+               Merge Cond: (b1t1.c1 = b1t2.c1)
+               ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                     Sort Key: bmt2.c1
-                     ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                     Sort Key: c1.c1
-                     ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+                     Sort Key: b1t2.c1
+                     ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+         ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t1.c1)
+               Filter: (c1 <> $1)
+   ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = b1t1.c1)
 
 -- No. R-2-2-3
 \o results/ut-R.tmpout
@@ -2773,45 +2731,31 @@ used hint:
 HashJoin(b1t3 b1t4)
 HashJoin(b2t3 b2t4)
 HashJoin(b3t3 b3t4)
-MergeJoin(bmt4 c1)
 NestLoop(b1t2 b1t3 b1t4)
 NestLoop(b2t2 b2t3 b2t4)
 NestLoop(b3t2 b3t3 b3t4)
-HashJoin(bmt3 bmt4 c1)
 MergeJoin(b1t1 b1t2 b1t3 b1t4)
 MergeJoin(b2t1 b2t2 b2t3 b2t4)
 MergeJoin(b3t1 b3t2 b3t3 b3t4)
-NestLoop(bmt2 bmt3 bmt4 c1)
-MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
-Leading(c1 bmt4 bmt3 bmt2 bmt1)
 Leading(b1t4 b1t3 b1t2 b1t1)
 Leading(b2t4 b2t3 b2t2 b2t1)
 Leading(b3t4 b3t3 b3t2 b3t1)
 not used hint:
+MergeJoin(bmt4 c1)
+HashJoin(bmt3 bmt4 c1)
+NestLoop(bmt2 bmt3 bmt4 c1)
+MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                    QUERY PLAN                                                    
-------------------------------------------------------------------------------------------------------------------
- Merge Join  (cost=xxx..xxx rows=10 width=xxx)
-   Merge Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-           Merge Cond: (b1t1.c1 = b1t2.c1)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
-           ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                 Sort Key: b1t2.c1
-                 ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-                       ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
-                             Hash Cond: (b1t3.c1 = b1t4.c1)
-                             ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                             ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
-                             Index Cond: (c1 = b1t3.c1)
-   InitPlan 2 (returns $3)
+                                                     QUERY PLAN                                                     
+--------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt4.c1)
+   InitPlan 1 (returns $1)
      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
            Merge Cond: (b2t1.c1 = b2t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
@@ -2825,7 +2769,7 @@ error hint:
                                    ->  Seq Scan on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
                        ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
                              Index Cond: (c1 = b2t3.c1)
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
            Merge Cond: (b3t1.c1 = b3t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
@@ -2839,23 +2783,34 @@ error hint:
                                    ->  Seq Scan on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
                        ->  Index Only Scan using t2_i1 on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
                              Index Cond: (c1 = b3t3.c1)
-   ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $5)
-   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-         Sort Key: bmt2.c1
-         ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                     Hash Cond: (bmt3.c1 = bmt4.c1)
-                     ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
-                     ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                           ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-                                 Merge Cond: (bmt4.c1 = c1.c1)
-                                 ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
-                                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                       Sort Key: c1.c1
-                                       ->  CTE Scan on c1  (cost=xxx..xxx rows=100 width=xxx)
+   ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+         Join Filter: (bmt1.c1 = bmt3.c1)
+         ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+               Join Filter: (bmt1.c1 = bmt2.c1)
+               ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
+                     Join Filter: (b1t1.c1 = bmt1.c1)
+                     ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
+                           Merge Cond: (b1t1.c1 = b1t2.c1)
+                           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
+                           ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+                                 Sort Key: b1t2.c1
+                                 ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                       ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
+                                             Hash Cond: (b1t3.c1 = b1t4.c1)
+                                             ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                             ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
+                                                   ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                       ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
+                                             Index Cond: (c1 = b1t3.c1)
+                     ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+                           Index Cond: (c1 = b1t3.c1)
+                           Filter: (c1 <> $3)
                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
-                     Index Cond: (c1 = bmt3.c1)
+                     Index Cond: (c1 = b1t3.c1)
+         ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t3.c1)
+   ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = bmt3.c1)
 
 \o results/ut-R.tmpout
 /*+
@@ -2906,58 +2861,44 @@ used hint:
 HashJoin(b1t3 b1t4)
 HashJoin(b2t3 b2t4)
 HashJoin(b3t3 b3t4)
-MergeJoin(bmt4 c1)
 NestLoop(b1t2 b1t3 b1t4)
 NestLoop(b2t2 b2t3 b2t4)
 NestLoop(b3t2 b3t3 b3t4)
-HashJoin(bmt3 bmt4 c1)
 MergeJoin(b1t1 b1t2 b1t3 b1t4)
 MergeJoin(b2t1 b2t2 b2t3 b2t4)
 MergeJoin(b3t1 b3t2 b3t3 b3t4)
-NestLoop(bmt2 bmt3 bmt4 c1)
-MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
-Leading(c1 bmt4 bmt3 bmt2 bmt1)
 Leading(b1t4 b1t3 b1t2 b1t1)
 Leading(b2t4 b2t3 b2t2 b2t1)
 Leading(b3t4 b3t3 b3t2 b3t1)
 Rows(b1t3 b1t4 #1)
 Rows(b2t3 b2t4 #1)
 Rows(b3t3 b3t4 #1)
-Rows(bmt4 c1 #1)
 Rows(b1t2 b1t3 b1t4 #1)
 Rows(b2t2 b2t3 b2t4 #1)
 Rows(b3t2 b3t3 b3t4 #1)
-Rows(bmt3 bmt4 c1 #1)
 Rows(b1t1 b1t2 b1t3 b1t4 #1)
 Rows(b2t1 b2t2 b2t3 b2t4 #1)
 Rows(b3t1 b3t2 b3t3 b3t4 #1)
+not used hint:
+MergeJoin(bmt4 c1)
+HashJoin(bmt3 bmt4 c1)
+NestLoop(bmt2 bmt3 bmt4 c1)
+MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
+Rows(bmt4 c1 #1)
+Rows(bmt3 bmt4 c1 #1)
 Rows(bmt2 bmt3 bmt4 c1 #1)
 Rows(bmt1 bmt2 bmt3 bmt4 c1 #1)
-not used hint:
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                    QUERY PLAN                                                    
-------------------------------------------------------------------------------------------------------------------
- Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-   Merge Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-           Merge Cond: (b1t1.c1 = b1t2.c1)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
-           ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                 Sort Key: b1t2.c1
-                 ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-                       ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                             Hash Cond: (b1t3.c1 = b1t4.c1)
-                             ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                             ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
-                                   ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
-                             Index Cond: (c1 = b1t3.c1)
-   InitPlan 2 (returns $3)
+                                                     QUERY PLAN                                                     
+--------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt4.c1)
+   InitPlan 1 (returns $1)
      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
            Merge Cond: (b2t1.c1 = b2t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
@@ -2971,7 +2912,7 @@ error hint:
                                    ->  Seq Scan on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
                        ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
                              Index Cond: (c1 = b2t3.c1)
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
            Merge Cond: (b3t1.c1 = b3t2.c1)
            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
@@ -2985,23 +2926,34 @@ error hint:
                                    ->  Seq Scan on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
                        ->  Index Only Scan using t2_i1 on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
                              Index Cond: (c1 = b3t3.c1)
-   ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $5)
-   ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-         Sort Key: bmt2.c1
-         ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                     Hash Cond: (bmt3.c1 = bmt4.c1)
-                     ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
-                     ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                           ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                 Merge Cond: (bmt4.c1 = c1.c1)
-                                 ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
-                                 ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                       Sort Key: c1.c1
-                                       ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
+   ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+         Join Filter: (bmt1.c1 = bmt3.c1)
+         ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+               Join Filter: (bmt1.c1 = bmt2.c1)
+               ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
+                     Join Filter: (b1t1.c1 = bmt1.c1)
+                     ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                           Merge Cond: (b1t1.c1 = b1t2.c1)
+                           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
+                           ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
+                                 Sort Key: b1t2.c1
+                                 ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                       ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                             Hash Cond: (b1t3.c1 = b1t4.c1)
+                                             ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                             ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
+                                                   ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                       ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
+                                             Index Cond: (c1 = b1t3.c1)
+                     ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+                           Index Cond: (c1 = b1t3.c1)
+                           Filter: (c1 <> $3)
                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
-                     Index Cond: (c1 = bmt3.c1)
+                     Index Cond: (c1 = b1t3.c1)
+         ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t3.c1)
+   ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = bmt3.c1)
 
 -- No. R-2-2-4
 \o results/ut-R.tmpout
@@ -3030,59 +2982,56 @@ SELECT b3t1.c1 FROM s1.t1 b3t1
 LOG:  pg_hint_plan:
 used hint:
 MergeJoin(b1t3 b1t4)
-MergeJoin(bmt4 c1)
 HashJoin(b1t2 b1t3 b1t4)
-HashJoin(bmt3 bmt4 c1)
 NestLoop(b1t1 b1t2 b1t3 b1t4)
+Leading(b1t4 b1t3 b1t2 b1t1)
+not used hint:
+MergeJoin(bmt4 c1)
+HashJoin(bmt3 bmt4 c1)
 NestLoop(bmt2 bmt3 bmt4 c1)
 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
 Leading(c1 bmt4 bmt3 bmt2 bmt1)
-Leading(b1t4 b1t3 b1t2 b1t1)
-not used hint:
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                    QUERY PLAN                                                    
-------------------------------------------------------------------------------------------------------------------
- Merge Join  (cost=xxx..xxx rows=10 width=xxx)
-   Merge Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-           Join Filter: (b1t2.c1 = b1t1.c1)
-           ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                 Hash Cond: (b1t3.c1 = b1t2.c1)
-                 ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
-                       Merge Cond: (b1t3.c1 = b1t4.c1)
-                       ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                 ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                       ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                 Index Cond: (c1 = b1t3.c1)
-   InitPlan 2 (returns $2)
+                                                          QUERY PLAN                                                          
+------------------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt4.c1)
+   InitPlan 1 (returns $0)
      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
-   InitPlan 3 (returns $3)
+   InitPlan 2 (returns $1)
      ->  Seq Scan on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
-   ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $3)
-   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-         Sort Key: bmt2.c1
-         ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
-                     Hash Cond: (bmt3.c1 = bmt4.c1)
-                     ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
-                     ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                           ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
-                                 Merge Cond: (bmt4.c1 = c1.c1)
-                                 ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
-                                 ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
-                                       Sort Key: c1.c1
-                                       ->  CTE Scan on c1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
-                     Index Cond: (c1 = bmt3.c1)
+   ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+         Join Filter: (bmt1.c1 = bmt3.c1)
+         ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+               Join Filter: (bmt2.c1 = bmt1.c1)
+               ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
+                     Join Filter: (b1t1.c1 = bmt2.c1)
+                     ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
+                     ->  Materialize  (cost=xxx..xxx rows=100 width=xxx)
+                           ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
+                                 Join Filter: (b1t2.c1 = b1t1.c1)
+                                 ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
+                                       Hash Cond: (b1t3.c1 = b1t2.c1)
+                                       ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
+                                             Merge Cond: (b1t3.c1 = b1t4.c1)
+                                             ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                             ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                             ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                       Index Cond: (c1 = b1t3.c1)
+               ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+                     Index Cond: (c1 = b1t3.c1)
+                     Filter: (c1 <> $1)
+         ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t3.c1)
+   ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = bmt3.c1)
 
 \o results/ut-R.tmpout
 /*+
@@ -3117,66 +3066,63 @@ SELECT b3t1.c1 FROM s1.t1 b3t1
 LOG:  pg_hint_plan:
 used hint:
 MergeJoin(b1t3 b1t4)
-MergeJoin(bmt4 c1)
 HashJoin(b1t2 b1t3 b1t4)
-HashJoin(bmt3 bmt4 c1)
 NestLoop(b1t1 b1t2 b1t3 b1t4)
+Leading(b1t4 b1t3 b1t2 b1t1)
+Rows(b1t3 b1t4 #1)
+Rows(b1t2 b1t3 b1t4 #1)
+Rows(b1t1 b1t2 b1t3 b1t4 #1)
+not used hint:
+MergeJoin(bmt4 c1)
+HashJoin(bmt3 bmt4 c1)
 NestLoop(bmt2 bmt3 bmt4 c1)
 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
 Leading(c1 bmt4 bmt3 bmt2 bmt1)
-Leading(b1t4 b1t3 b1t2 b1t1)
-Rows(b1t3 b1t4 #1)
 Rows(bmt4 c1 #1)
-Rows(b1t2 b1t3 b1t4 #1)
 Rows(bmt3 bmt4 c1 #1)
-Rows(b1t1 b1t2 b1t3 b1t4 #1)
 Rows(bmt2 bmt3 bmt4 c1 #1)
 Rows(bmt1 bmt2 bmt3 bmt4 c1 #1)
-not used hint:
 duplication hint:
 error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                                                    QUERY PLAN                                                    
-------------------------------------------------------------------------------------------------------------------
- Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-   Merge Cond: (bmt1.c1 = bmt2.c1)
-   CTE c1
-     ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-           Join Filter: (b1t2.c1 = b1t1.c1)
-           ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                 Hash Cond: (b1t3.c1 = b1t2.c1)
-                 ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                       Merge Cond: (b1t3.c1 = b1t4.c1)
-                       ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
-                       ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
-                 ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
-                       ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
-           ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
-                 Index Cond: (c1 = b1t3.c1)
-   InitPlan 2 (returns $2)
+                                                          QUERY PLAN                                                          
+------------------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+   Join Filter: (bmt1.c1 = bmt4.c1)
+   InitPlan 1 (returns $0)
      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
            Index Cond: (c1 = 1)
-   InitPlan 3 (returns $3)
+   InitPlan 2 (returns $1)
      ->  Seq Scan on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
-   ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=999 width=xxx)
-         Filter: (c1 <> $3)
-   ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-         Sort Key: bmt2.c1
-         ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
-                     Hash Cond: (bmt3.c1 = bmt4.c1)
-                     ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
-                     ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
-                           ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
-                                 Merge Cond: (bmt4.c1 = c1.c1)
-                                 ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
-                                 ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
-                                       Sort Key: c1.c1
-                                       ->  CTE Scan on c1  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
-                     Index Cond: (c1 = bmt3.c1)
+   ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+         Join Filter: (bmt1.c1 = bmt3.c1)
+         ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
+               Join Filter: (bmt2.c1 = bmt1.c1)
+               ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
+                     Join Filter: (b1t1.c1 = bmt2.c1)
+                     ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
+                     ->  Materialize  (cost=xxx..xxx rows=1 width=xxx)
+                           ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
+                                 Join Filter: (b1t2.c1 = b1t1.c1)
+                                 ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
+                                       Hash Cond: (b1t3.c1 = b1t2.c1)
+                                       ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+                                             Merge Cond: (b1t3.c1 = b1t4.c1)
+                                             ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
+                                             ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
+                                       ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
+                                             ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
+                                 ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
+                                       Index Cond: (c1 = b1t3.c1)
+               ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
+                     Index Cond: (c1 = b1t3.c1)
+                     Filter: (c1 <> $1)
+         ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
+               Index Cond: (c1 = b1t3.c1)
+   ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
+         Index Cond: (c1 = bmt3.c1)
 
 ----
 ---- No. R-2-3 RULE or VIEW
@@ -4750,27 +4696,27 @@ error hint:
 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                               QUERY PLAN                                
--------------------------------------------------------------------------
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
    Hash Cond: (p2.c1 = p1.c1)
    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
-         ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2 p2_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1 p2_2  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c2 p2_3  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c3 p2_4  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1c1 p2_5  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c1c2 p2_6  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c1 p2_7  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c2 p2_8  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c1 p2_9  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c2 p2_10  (cost=xxx..xxx rows=50 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 p1_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 p1_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 p1_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 p1_4  (cost=xxx..xxx rows=100 width=xxx)
 
 \o results/ut-R.tmpout
 /*+Rows(p1 p2 #1)*/
@@ -4784,54 +4730,54 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                               QUERY PLAN                                
--------------------------------------------------------------------------
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
    Hash Cond: (p2.c1 = p1.c1)
    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
-         ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2 p2_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1 p2_2  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c2 p2_3  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c3 p2_4  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1c1 p2_5  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c1c2 p2_6  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c1 p2_7  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c2 p2_8  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c1 p2_9  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c2 p2_10  (cost=xxx..xxx rows=50 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 p1_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 p1_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 p1_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 p1_4  (cost=xxx..xxx rows=100 width=xxx)
 
 -- No. R-3-4-2
 \o results/ut-R.tmpout
 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                               QUERY PLAN                                
--------------------------------------------------------------------------
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
    Hash Cond: (p2.c1 = p1.c1)
    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
-         ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2 p2_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1 p2_2  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c2 p2_3  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c3 p2_4  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1c1 p2_5  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c1c2 p2_6  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c1 p2_7  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c2 p2_8  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c1 p2_9  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c2 p2_10  (cost=xxx..xxx rows=50 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 p1_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 p1_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 p1_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 p1_4  (cost=xxx..xxx rows=100 width=xxx)
 
 \o results/ut-R.tmpout
 /*+Rows(p1c1 p2c1 #1)*/
@@ -4845,27 +4791,27 @@ error hint:
 
 \o
 \! sql/maskout.sh results/ut-R.tmpout
-                               QUERY PLAN                                
--------------------------------------------------------------------------
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
    Hash Cond: (p2.c1 = p1.c1)
    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
-         ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
-         ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
-         ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2 p2_1  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1 p2_2  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c2 p2_3  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c3 p2_4  (cost=xxx..xxx rows=1 width=xxx)
+         ->  Seq Scan on p2c1c1 p2_5  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c1c2 p2_6  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c1 p2_7  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c2c2 p2_8  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c1 p2_9  (cost=xxx..xxx rows=50 width=xxx)
+         ->  Seq Scan on p2c3c2 p2_10  (cost=xxx..xxx rows=50 width=xxx)
    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
-               ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
-               ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
-               ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1 p1_1  (cost=xxx..xxx rows=1 width=xxx)
+               ->  Seq Scan on p1c1 p1_2  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c2 p1_3  (cost=xxx..xxx rows=100 width=xxx)
+               ->  Seq Scan on p1c3 p1_4  (cost=xxx..xxx rows=100 width=xxx)
 
 ----
 ---- No. R-3-5 conflict join method hint