OSDN Git Service

Follow core's cobe/havor chages
[pghintplan/pg_hint_plan.git] / expected / ut-R.out
1 LOAD 'pg_hint_plan';
2 SET pg_hint_plan.enable_hint TO on;
3 SET pg_hint_plan.debug_print TO on;
4 SET client_min_messages TO LOG;
5 SET search_path TO public;
6 \o results/ut-R.tmpout
7 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
8 \o
9 \! sql/maskout.sh results/ut-R.tmpout
10                                 QUERY PLAN                                 
11 ---------------------------------------------------------------------------
12  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
13    Merge Cond: (t1.c1 = t2.c1)
14    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
15    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
16          Sort Key: t2.c1
17          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
18
19 ----
20 ---- No. R-1-1 specified pattern of the object name
21 ----
22 -- No. R-1-1-1
23 \o results/ut-R.tmpout
24 /*+Rows(t1 t2 #1)*/
25 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
26 LOG:  pg_hint_plan:
27 used hint:
28 Rows(t1 t2 #1)
29 not used hint:
30 duplication hint:
31 error hint:
32
33 \o
34 \! sql/maskout.sh results/ut-R.tmpout
35                                 QUERY PLAN                                 
36 ---------------------------------------------------------------------------
37  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
38    Merge Cond: (t1.c1 = t2.c1)
39    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
40    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
41          Sort Key: t2.c1
42          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
43
44 -- No. R-1-1-2
45 \o results/ut-R.tmpout
46 /*+Rows(t1 t2 #1)*/
47 EXPLAIN SELECT * FROM s1.t1 t_1, s1.t2 t_2 WHERE t_1.c1 = t_2.c1;
48 LOG:  pg_hint_plan:
49 used hint:
50 not used hint:
51 Rows(t1 t2 #1)
52 duplication hint:
53 error hint:
54
55 \o
56 \! sql/maskout.sh results/ut-R.tmpout
57                                   QUERY PLAN                                   
58 -------------------------------------------------------------------------------
59  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
60    Merge Cond: (t_1.c1 = t_2.c1)
61    ->  Index Scan using t1_i1 on t1 t_1  (cost=xxx..xxx rows=1000 width=xxx)
62    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
63          Sort Key: t_2.c1
64          ->  Seq Scan on t2 t_2  (cost=xxx..xxx rows=100 width=xxx)
65
66 -- No. R-1-1-3
67 \o results/ut-R.tmpout
68 /*+Rows(t_1 t_2 #1)*/
69 EXPLAIN SELECT * FROM s1.t1 t_1, s1.t2 t_2 WHERE t_1.c1 = t_2.c1;
70 LOG:  pg_hint_plan:
71 used hint:
72 Rows(t_1 t_2 #1)
73 not used hint:
74 duplication hint:
75 error hint:
76
77 \o
78 \! sql/maskout.sh results/ut-R.tmpout
79                                   QUERY PLAN                                   
80 -------------------------------------------------------------------------------
81  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
82    Merge Cond: (t_1.c1 = t_2.c1)
83    ->  Index Scan using t1_i1 on t1 t_1  (cost=xxx..xxx rows=1000 width=xxx)
84    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
85          Sort Key: t_2.c1
86          ->  Seq Scan on t2 t_2  (cost=xxx..xxx rows=100 width=xxx)
87
88 ----
89 ---- No. R-1-2 specified schema name in the hint option
90 ----
91 -- No. R-1-2-1
92 \o results/ut-R.tmpout
93 /*+Rows(t1 t2 #1)*/
94 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
95 LOG:  pg_hint_plan:
96 used hint:
97 Rows(t1 t2 #1)
98 not used hint:
99 duplication hint:
100 error hint:
101
102 \o
103 \! sql/maskout.sh results/ut-R.tmpout
104                                 QUERY PLAN                                 
105 ---------------------------------------------------------------------------
106  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
107    Merge Cond: (t1.c1 = t2.c1)
108    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
109    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
110          Sort Key: t2.c1
111          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
112
113 -- No. R-1-2-2
114 \o results/ut-R.tmpout
115 /*+Rows(s1.t1 s1.t2 #1)*/
116 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
117 LOG:  pg_hint_plan:
118 used hint:
119 not used hint:
120 Rows(s1.t1 s1.t2 #1)
121 duplication hint:
122 error hint:
123
124 \o
125 \! sql/maskout.sh results/ut-R.tmpout
126                                 QUERY PLAN                                 
127 ---------------------------------------------------------------------------
128  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
129    Merge Cond: (t1.c1 = t2.c1)
130    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
131    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
132          Sort Key: t2.c1
133          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
134
135 ----
136 ---- No. R-1-3 table doesn't exist in the hint option
137 ----
138 -- No. R-1-3-1
139 \o results/ut-R.tmpout
140 /*+Rows(t1 t2 #1)*/
141 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
142 LOG:  pg_hint_plan:
143 used hint:
144 Rows(t1 t2 #1)
145 not used hint:
146 duplication hint:
147 error hint:
148
149 \o
150 \! sql/maskout.sh results/ut-R.tmpout
151                                 QUERY PLAN                                 
152 ---------------------------------------------------------------------------
153  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
154    Merge Cond: (t1.c1 = t2.c1)
155    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
156    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
157          Sort Key: t2.c1
158          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
159
160 -- No. R-1-3-2
161 \o results/ut-R.tmpout
162 /*+Rows(t3 t4 #1)*/
163 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
164 LOG:  pg_hint_plan:
165 used hint:
166 not used hint:
167 Rows(t3 t4 #1)
168 duplication hint:
169 error hint:
170
171 \o
172 \! sql/maskout.sh results/ut-R.tmpout
173                                 QUERY PLAN                                 
174 ---------------------------------------------------------------------------
175  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
176    Merge Cond: (t1.c1 = t2.c1)
177    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
178    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
179          Sort Key: t2.c1
180          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
181
182 ----
183 ---- No. R-1-4 conflict table name
184 ----
185 -- No. R-1-4-1
186 \o results/ut-R.tmpout
187 /*+Rows(t1 t2 #1)*/
188 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
189 LOG:  pg_hint_plan:
190 used hint:
191 Rows(t1 t2 #1)
192 not used hint:
193 duplication hint:
194 error hint:
195
196 \o
197 \! sql/maskout.sh results/ut-R.tmpout
198                                 QUERY PLAN                                 
199 ---------------------------------------------------------------------------
200  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
201    Merge Cond: (t1.c1 = t2.c1)
202    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
203    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
204          Sort Key: t2.c1
205          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
206
207 -- No. R-1-4-2
208 \o results/ut-R.tmpout
209 EXPLAIN SELECT * FROM s1.t1, s2.t1 WHERE s1.t1.c1 = s2.t1.c1;
210 \o
211 \! sql/maskout.sh results/ut-R.tmpout
212                                 QUERY PLAN                                 
213 ---------------------------------------------------------------------------
214  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
215    Merge Cond: (t1.c1 = t1_1.c1)
216    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
217    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
218          Sort Key: t1_1.c1
219          ->  Seq Scan on t1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
220
221 \o results/ut-R.tmpout
222 /*+Rows(t1 t1 #1)*/
223 EXPLAIN SELECT * FROM s1.t1, s2.t1 WHERE s1.t1.c1 = s2.t1.c1;
224 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t1 #1)"
225 DETAIL:  Relation name "t1" is ambiguous.
226 LOG:  pg_hint_plan:
227 used hint:
228 not used hint:
229 duplication hint:
230 error hint:
231 Rows(t1 t1 #1)
232
233 \o
234 \! sql/maskout.sh results/ut-R.tmpout
235                                 QUERY PLAN                                 
236 ---------------------------------------------------------------------------
237  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
238    Merge Cond: (t1.c1 = t1_1.c1)
239    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
240    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
241          Sort Key: t1_1.c1
242          ->  Seq Scan on t1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
243
244 \o results/ut-R.tmpout
245 /*+Rows(s1.t1 s2.t1 #1)*/
246 EXPLAIN SELECT * FROM s1.t1, s2.t1 WHERE s1.t1.c1 = s2.t1.c1;
247 LOG:  pg_hint_plan:
248 used hint:
249 not used hint:
250 Rows(s1.t1 s2.t1 #1)
251 duplication hint:
252 error hint:
253
254 \o
255 \! sql/maskout.sh results/ut-R.tmpout
256                                 QUERY PLAN                                 
257 ---------------------------------------------------------------------------
258  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
259    Merge Cond: (t1.c1 = t1_1.c1)
260    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
261    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
262          Sort Key: t1_1.c1
263          ->  Seq Scan on t1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
264
265 \o results/ut-R.tmpout
266 EXPLAIN SELECT * FROM s1.t1, s2.t1 s2t1 WHERE s1.t1.c1 = s2t1.c1;
267 \o
268 \! sql/maskout.sh results/ut-R.tmpout
269                                 QUERY PLAN                                 
270 ---------------------------------------------------------------------------
271  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
272    Merge Cond: (t1.c1 = s2t1.c1)
273    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
274    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
275          Sort Key: s2t1.c1
276          ->  Seq Scan on t1 s2t1  (cost=xxx..xxx rows=100 width=xxx)
277
278 \o results/ut-R.tmpout
279 /*+Rows(t1 s2t1 #1)*/
280 EXPLAIN SELECT * FROM s1.t1, s2.t1 s2t1 WHERE s1.t1.c1 = s2t1.c1;
281 LOG:  pg_hint_plan:
282 used hint:
283 Rows(s2t1 t1 #1)
284 not used hint:
285 duplication hint:
286 error hint:
287
288 \o
289 \! sql/maskout.sh results/ut-R.tmpout
290                                 QUERY PLAN                                 
291 ---------------------------------------------------------------------------
292  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
293    Merge Cond: (t1.c1 = s2t1.c1)
294    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
295    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
296          Sort Key: s2t1.c1
297          ->  Seq Scan on t1 s2t1  (cost=xxx..xxx rows=100 width=xxx)
298
299 -- No. R-1-4-3
300 \o results/ut-R.tmpout
301 EXPLAIN SELECT *, (SELECT max(t1.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
302 \o
303 \! sql/maskout.sh results/ut-R.tmpout
304                                             QUERY PLAN                                            
305 --------------------------------------------------------------------------------------------------
306  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
307    Merge Cond: (t1.c1 = t2.c1)
308    InitPlan 1 (returns $0)
309      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
310            ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
311                  Merge Cond: (t1_1.c1 = t2_1.c1)
312                  ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
313                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
314                        Sort Key: t2_1.c1
315                        ->  Seq Scan on t2 t2_1  (cost=xxx..xxx rows=100 width=xxx)
316    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
317    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
318          Sort Key: t2.c1
319          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
320
321 \o results/ut-R.tmpout
322 /*+Rows(t1 t2 #1)*/
323 EXPLAIN SELECT *, (SELECT max(t1.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
324 LOG:  pg_hint_plan:
325 used hint:
326 Rows(t1 t2 #1)
327 not used hint:
328 duplication hint:
329 error hint:
330
331 \o
332 \! sql/maskout.sh results/ut-R.tmpout
333                                             QUERY PLAN                                            
334 --------------------------------------------------------------------------------------------------
335  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
336    Merge Cond: (t1.c1 = t2.c1)
337    InitPlan 1 (returns $0)
338      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
339            ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
340                  Merge Cond: (t1_1.c1 = t2_1.c1)
341                  ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
342                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
343                        Sort Key: t2_1.c1
344                        ->  Seq Scan on t2 t2_1  (cost=xxx..xxx rows=100 width=xxx)
345    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
346    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
347          Sort Key: t2.c1
348          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
349
350 \o results/ut-R.tmpout
351 /*+Rows(st1 st2 #1)Rows(t1 t2 #1)*/
352 EXPLAIN SELECT *, (SELECT max(st1.c1) FROM s1.t1 st1, s1.t2 st2 WHERE st1.c1 = st2.c1) FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
353 LOG:  pg_hint_plan:
354 used hint:
355 Rows(st1 st2 #1)
356 Rows(t1 t2 #1)
357 not used hint:
358 duplication hint:
359 error hint:
360
361 \o
362 \! sql/maskout.sh results/ut-R.tmpout
363                                            QUERY PLAN                                            
364 -------------------------------------------------------------------------------------------------
365  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
366    Merge Cond: (t1.c1 = t2.c1)
367    InitPlan 1 (returns $0)
368      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
369            ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
370                  Merge Cond: (st1.c1 = st2.c1)
371                  ->  Index Only Scan using t1_i1 on t1 st1  (cost=xxx..xxx rows=1000 width=xxx)
372                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
373                        Sort Key: st2.c1
374                        ->  Seq Scan on t2 st2  (cost=xxx..xxx rows=100 width=xxx)
375    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
376    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
377          Sort Key: t2.c1
378          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
379
380 ----
381 ---- No. R-1-5 conflict table name
382 ----
383 -- No. R-1-5-1
384 \o results/ut-R.tmpout
385 /*+Rows(t1 t2 #1)*/
386 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
387 LOG:  pg_hint_plan:
388 used hint:
389 Rows(t1 t2 #1)
390 not used hint:
391 duplication hint:
392 error hint:
393
394 \o
395 \! sql/maskout.sh results/ut-R.tmpout
396                                 QUERY PLAN                                 
397 ---------------------------------------------------------------------------
398  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
399    Merge Cond: (t1.c1 = t2.c1)
400    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
401    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
402          Sort Key: t2.c1
403          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
404
405 -- No. R-1-5-2
406 \o results/ut-R.tmpout
407 /*+Rows(t1 t1 #1)*/
408 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
409 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t1 #1)"
410 DETAIL:  Relation name "t1" is duplicated.
411 LOG:  pg_hint_plan:
412 used hint:
413 not used hint:
414 duplication hint:
415 error hint:
416 Rows(t1 t1 #1)
417
418 \o
419 \! sql/maskout.sh results/ut-R.tmpout
420                                 QUERY PLAN                                 
421 ---------------------------------------------------------------------------
422  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
423    Merge Cond: (t1.c1 = t2.c1)
424    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
425    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
426          Sort Key: t2.c1
427          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
428
429 -- No. R-1-5-3
430 \o results/ut-R.tmpout
431 /*+(t1 t1)(t2 t2)*/
432 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
433 INFO:  pg_hint_plan: hint syntax error at or near "(t1 t1)(t2 t2)"
434 DETAIL:  Unrecognized hint keyword "".
435 \o
436 \! sql/maskout.sh results/ut-R.tmpout
437                                 QUERY PLAN                                 
438 ---------------------------------------------------------------------------
439  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
440    Merge Cond: (t1.c1 = t2.c1)
441    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
442    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
443          Sort Key: t2.c1
444          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
445
446 \o results/ut-R.tmpout
447 EXPLAIN SELECT * FROM s1.t1, s1.t2, s1.t3 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
448 \o
449 \! sql/maskout.sh results/ut-R.tmpout
450                                    QUERY PLAN                                    
451 ---------------------------------------------------------------------------------
452  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
453    Merge Cond: (t1.c1 = t2.c1)
454    ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
455          Merge Cond: (t1.c1 = t3.c1)
456          ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
457          ->  Index Scan using t3_i1 on t3  (cost=xxx..xxx rows=1130 width=xxx)
458    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
459          Sort Key: t2.c1
460          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
461
462 \o results/ut-R.tmpout
463 /*+(t1 t2 t1 t2)*/
464 EXPLAIN SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
465 INFO:  pg_hint_plan: hint syntax error at or near "(t1 t2 t1 t2)"
466 DETAIL:  Unrecognized hint keyword "".
467 \o
468 \! sql/maskout.sh results/ut-R.tmpout
469                                       QUERY PLAN                                       
470 ---------------------------------------------------------------------------------------
471  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
472    ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
473          Merge Cond: (t1.c1 = t2.c1)
474          ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
475                Merge Cond: (t1.c1 = t3.c1)
476                ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
477                ->  Index Scan using t3_i1 on t3  (cost=xxx..xxx rows=1130 width=xxx)
478          ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
479                Sort Key: t2.c1
480                ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
481    ->  Index Scan using t4_i1 on t4  (cost=xxx..xxx rows=1 width=xxx)
482          Index Cond: (c1 = t1.c1)
483
484 ----
485 ---- No. R-1-6 object type for the hint
486 ----
487 -- No. R-1-6-1
488 \o results/ut-R.tmpout
489 /*+Rows(t1 t2 #1)*/
490 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
491 LOG:  pg_hint_plan:
492 used hint:
493 Rows(t1 t2 #1)
494 not used hint:
495 duplication hint:
496 error hint:
497
498 \o
499 \! sql/maskout.sh results/ut-R.tmpout
500                                 QUERY PLAN                                 
501 ---------------------------------------------------------------------------
502  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
503    Merge Cond: (t1.c1 = t2.c1)
504    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
505    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
506          Sort Key: t2.c1
507          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
508
509 -- No. R-1-6-2
510 \o results/ut-R.tmpout
511 EXPLAIN SELECT * FROM s1.p1 t1, s1.p1 t2 WHERE t1.c1 = t2.c1;
512 \o
513 \! sql/maskout.sh results/ut-R.tmpout
514                                   QUERY PLAN                                  
515 ------------------------------------------------------------------------------
516  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
517    Hash Cond: (t1.c1 = t2.c1)
518    ->  Append  (cost=xxx..xxx rows=301 width=xxx)
519          ->  Seq Scan on p1 t1  (cost=xxx..xxx rows=1 width=xxx)
520          ->  Seq Scan on p1c1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
521          ->  Seq Scan on p1c2 t1_2  (cost=xxx..xxx rows=100 width=xxx)
522          ->  Seq Scan on p1c3 t1_3  (cost=xxx..xxx rows=100 width=xxx)
523    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
524          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
525                ->  Seq Scan on p1 t2  (cost=xxx..xxx rows=1 width=xxx)
526                ->  Seq Scan on p1c1 t2_1  (cost=xxx..xxx rows=100 width=xxx)
527                ->  Seq Scan on p1c2 t2_2  (cost=xxx..xxx rows=100 width=xxx)
528                ->  Seq Scan on p1c3 t2_3  (cost=xxx..xxx rows=100 width=xxx)
529
530 \o results/ut-R.tmpout
531 /*+Rows(t1 t2 #1)*/
532 EXPLAIN SELECT * FROM s1.p1 t1, s1.p1 t2 WHERE t1.c1 = t2.c1;
533 LOG:  pg_hint_plan:
534 used hint:
535 Rows(t1 t2 #1)
536 not used hint:
537 duplication hint:
538 error hint:
539
540 \o
541 \! sql/maskout.sh results/ut-R.tmpout
542                                   QUERY PLAN                                  
543 ------------------------------------------------------------------------------
544  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
545    Hash Cond: (t1.c1 = t2.c1)
546    ->  Append  (cost=xxx..xxx rows=301 width=xxx)
547          ->  Seq Scan on p1 t1  (cost=xxx..xxx rows=1 width=xxx)
548          ->  Seq Scan on p1c1 t1_1  (cost=xxx..xxx rows=100 width=xxx)
549          ->  Seq Scan on p1c2 t1_2  (cost=xxx..xxx rows=100 width=xxx)
550          ->  Seq Scan on p1c3 t1_3  (cost=xxx..xxx rows=100 width=xxx)
551    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
552          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
553                ->  Seq Scan on p1 t2  (cost=xxx..xxx rows=1 width=xxx)
554                ->  Seq Scan on p1c1 t2_1  (cost=xxx..xxx rows=100 width=xxx)
555                ->  Seq Scan on p1c2 t2_2  (cost=xxx..xxx rows=100 width=xxx)
556                ->  Seq Scan on p1c3 t2_3  (cost=xxx..xxx rows=100 width=xxx)
557
558 -- No. R-1-6-3
559 \o results/ut-R.tmpout
560 EXPLAIN SELECT * FROM s1.ul1 t1, s1.ul1 t2 WHERE t1.c1 = t2.c1;
561 \o
562 \! sql/maskout.sh results/ut-R.tmpout
563                               QUERY PLAN                               
564 -----------------------------------------------------------------------
565  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
566    Hash Cond: (t1.c1 = t2.c1)
567    ->  Seq Scan on ul1 t1  (cost=xxx..xxx rows=1130 width=xxx)
568    ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
569          ->  Seq Scan on ul1 t2  (cost=xxx..xxx rows=1130 width=xxx)
570
571 \o results/ut-R.tmpout
572 /*+Rows(t1 t2 #1)*/
573 EXPLAIN SELECT * FROM s1.ul1 t1, s1.ul1 t2 WHERE t1.c1 = t2.c1;
574 LOG:  pg_hint_plan:
575 used hint:
576 Rows(t1 t2 #1)
577 not used hint:
578 duplication hint:
579 error hint:
580
581 \o
582 \! sql/maskout.sh results/ut-R.tmpout
583                               QUERY PLAN                               
584 -----------------------------------------------------------------------
585  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
586    Hash Cond: (t1.c1 = t2.c1)
587    ->  Seq Scan on ul1 t1  (cost=xxx..xxx rows=1130 width=xxx)
588    ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
589          ->  Seq Scan on ul1 t2  (cost=xxx..xxx rows=1130 width=xxx)
590
591 -- No. R-1-6-4
592 CREATE TEMP TABLE tm1 (LIKE s1.t1 INCLUDING ALL);
593 \o results/ut-R.tmpout
594 EXPLAIN SELECT * FROM tm1 t1, tm1 t2 WHERE t1.c1 = t2.c1;
595 \o
596 \! sql/maskout.sh results/ut-R.tmpout
597                               QUERY PLAN                               
598 -----------------------------------------------------------------------
599  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
600    Hash Cond: (t1.c1 = t2.c1)
601    ->  Seq Scan on tm1 t1  (cost=xxx..xxx rows=1130 width=xxx)
602    ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
603          ->  Seq Scan on tm1 t2  (cost=xxx..xxx rows=1130 width=xxx)
604
605 \o results/ut-R.tmpout
606 /*+Rows(t1 t2 #1)*/
607 EXPLAIN SELECT * FROM tm1 t1, tm1 t2 WHERE t1.c1 = t2.c1;
608 LOG:  pg_hint_plan:
609 used hint:
610 Rows(t1 t2 #1)
611 not used hint:
612 duplication hint:
613 error hint:
614
615 \o
616 \! sql/maskout.sh results/ut-R.tmpout
617                               QUERY PLAN                               
618 -----------------------------------------------------------------------
619  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
620    Hash Cond: (t1.c1 = t2.c1)
621    ->  Seq Scan on tm1 t1  (cost=xxx..xxx rows=1130 width=xxx)
622    ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
623          ->  Seq Scan on tm1 t2  (cost=xxx..xxx rows=1130 width=xxx)
624
625 -- No. R-1-6-5
626 CREATE TEMP TABLE t_pg_class AS SELECT * from pg_class LIMIT 100;
627 \o results/ut-R.tmpout
628 EXPLAIN SELECT * FROM t_pg_class t1, t_pg_class t2 WHERE t1.oid = t2.oid;
629 \o
630 \! sql/maskout.sh results/ut-R.tmpout
631                                   QUERY PLAN                                  
632 ------------------------------------------------------------------------------
633  Hash Join  (cost=xxx..xxx rows=450 width=xxx)
634    Hash Cond: (t1.oid = t2.oid)
635    ->  Seq Scan on t_pg_class t1  (cost=xxx..xxx rows=300 width=xxx)
636    ->  Hash  (cost=xxx..xxx rows=300 width=xxx)
637          ->  Seq Scan on t_pg_class t2  (cost=xxx..xxx rows=300 width=xxx)
638
639 \o results/ut-R.tmpout
640 /*+Rows(t1 t2 #1)*/
641 EXPLAIN SELECT * FROM t_pg_class t1, t_pg_class t2 WHERE t1.oid = t2.oid;
642 LOG:  pg_hint_plan:
643 used hint:
644 Rows(t1 t2 #1)
645 not used hint:
646 duplication hint:
647 error hint:
648
649 \o
650 \! sql/maskout.sh results/ut-R.tmpout
651                                   QUERY PLAN                                  
652 ------------------------------------------------------------------------------
653  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
654    Hash Cond: (t1.oid = t2.oid)
655    ->  Seq Scan on t_pg_class t1  (cost=xxx..xxx rows=300 width=xxx)
656    ->  Hash  (cost=xxx..xxx rows=300 width=xxx)
657          ->  Seq Scan on t_pg_class t2  (cost=xxx..xxx rows=300 width=xxx)
658
659 -- No. R-1-6-6
660 -- refer ut-fdw.sql
661 -- No. R-1-6-7
662 \o results/ut-R.tmpout
663 EXPLAIN SELECT * FROM s1.f1() t1, s1.f1() t2 WHERE t1.c1 = t2.c1;
664 \o
665 \! sql/maskout.sh results/ut-R.tmpout
666                            QUERY PLAN                            
667 -----------------------------------------------------------------
668  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
669    Join Filter: (t1.c1 = t2.c1)
670    ->  Function Scan on f1 t1  (cost=xxx..xxx rows=1 width=xxx)
671    ->  Function Scan on f1 t2  (cost=xxx..xxx rows=1 width=xxx)
672
673 \o results/ut-R.tmpout
674 /*+Rows(t1 t2 #1)*/
675 EXPLAIN SELECT * FROM s1.f1() t1, s1.f1() t2 WHERE t1.c1 = t2.c1;
676 LOG:  pg_hint_plan:
677 used hint:
678 Rows(t1 t2 #1)
679 not used hint:
680 duplication hint:
681 error hint:
682
683 \o
684 \! sql/maskout.sh results/ut-R.tmpout
685                            QUERY PLAN                            
686 -----------------------------------------------------------------
687  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
688    Join Filter: (t1.c1 = t2.c1)
689    ->  Function Scan on f1 t1  (cost=xxx..xxx rows=1 width=xxx)
690    ->  Function Scan on f1 t2  (cost=xxx..xxx rows=1 width=xxx)
691
692 -- No. R-1-6-8
693 \o results/ut-R.tmpout
694 EXPLAIN SELECT * FROM (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3')) AS t1 (c1, c2, c3, c4),  s1.t2 WHERE t1.c1 = t2.c1;
695 \o
696 \! sql/maskout.sh results/ut-R.tmpout
697                                 QUERY PLAN                                
698 --------------------------------------------------------------------------
699  Hash Join  (cost=xxx..xxx rows=3 width=xxx)
700    Hash Cond: (t2.c1 = "*VALUES*".column1)
701    ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
702    ->  Hash  (cost=xxx..xxx rows=3 width=xxx)
703          ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=3 width=xxx)
704
705 \o results/ut-R.tmpout
706 /*+Rows(t1 t2 #1)*/
707 EXPLAIN SELECT * FROM (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3')) AS t1 (c1, c2, c3, c4),  s1.t2 WHERE t1.c1 = t2.c1;
708 LOG:  pg_hint_plan:
709 used hint:
710 not used hint:
711 Rows(t1 t2 #1)
712 duplication hint:
713 error hint:
714
715 \o
716 \! sql/maskout.sh results/ut-R.tmpout
717                                 QUERY PLAN                                
718 --------------------------------------------------------------------------
719  Hash Join  (cost=xxx..xxx rows=3 width=xxx)
720    Hash Cond: (t2.c1 = "*VALUES*".column1)
721    ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
722    ->  Hash  (cost=xxx..xxx rows=3 width=xxx)
723          ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=3 width=xxx)
724
725 \o results/ut-R.tmpout
726 /*+Rows(*VALUES* t2 #1)*/
727 EXPLAIN SELECT * FROM (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3')) AS t1 (c1, c2, c3, c4),  s1.t2 WHERE t1.c1 = t2.c1;
728 LOG:  pg_hint_plan:
729 used hint:
730 Rows(*VALUES* t2 #1)
731 not used hint:
732 duplication hint:
733 error hint:
734
735 \o
736 \! sql/maskout.sh results/ut-R.tmpout
737                                 QUERY PLAN                                
738 --------------------------------------------------------------------------
739  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
740    Hash Cond: (t2.c1 = "*VALUES*".column1)
741    ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
742    ->  Hash  (cost=xxx..xxx rows=3 width=xxx)
743          ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=3 width=xxx)
744
745 -- No. R-1-6-9
746 \o results/ut-R.tmpout
747 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;
748 \o
749 \! sql/maskout.sh results/ut-R.tmpout
750                                            QUERY PLAN                                           
751 ------------------------------------------------------------------------------------------------
752  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
753    ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
754          ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
755                Merge Cond: (t1_1.c1 = t2.c1)
756                ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
757                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
758                      Sort Key: t2.c1
759                      ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
760    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
761          Index Cond: (c1 = (max(t1_1.c1)))
762
763 \o results/ut-R.tmpout
764 /*+Rows(t1 t2 #1)Rows(t1 c1 +1)*/
765 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;
766 LOG:  pg_hint_plan:
767 used hint:
768 Rows(c1 t1 +1)
769 Rows(t1 t2 #1)
770 not used hint:
771 duplication hint:
772 error hint:
773
774 \o
775 \! sql/maskout.sh results/ut-R.tmpout
776                                            QUERY PLAN                                           
777 ------------------------------------------------------------------------------------------------
778  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
779    ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
780          ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
781                Merge Cond: (t1_1.c1 = t2.c1)
782                ->  Index Only Scan using t1_i1 on t1 t1_1  (cost=xxx..xxx rows=1000 width=xxx)
783                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
784                      Sort Key: t2.c1
785                      ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
786    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
787          Index Cond: (c1 = (max(t1_1.c1)))
788
789 -- No. R-1-6-10
790 \o results/ut-R.tmpout
791 EXPLAIN SELECT * FROM s1.v1 t1, s1.v1 t2 WHERE t1.c1 = t2.c1;
792 \o
793 \! sql/maskout.sh results/ut-R.tmpout
794                                 QUERY PLAN                                
795 --------------------------------------------------------------------------
796  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
797    Hash Cond: (v1t1.c1 = v1t1_1.c1)
798    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
799    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
800          ->  Seq Scan on t1 v1t1_1  (cost=xxx..xxx rows=1000 width=xxx)
801
802 \o results/ut-R.tmpout
803 /*+Rows(t1 t2 #1)*/
804 EXPLAIN SELECT * FROM s1.v1 t1, s1.v1 t2 WHERE t1.c1 = t2.c1;
805 LOG:  pg_hint_plan:
806 used hint:
807 not used hint:
808 Rows(t1 t2 #1)
809 duplication hint:
810 error hint:
811
812 \o
813 \! sql/maskout.sh results/ut-R.tmpout
814                                 QUERY PLAN                                
815 --------------------------------------------------------------------------
816  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
817    Hash Cond: (v1t1.c1 = v1t1_1.c1)
818    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
819    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
820          ->  Seq Scan on t1 v1t1_1  (cost=xxx..xxx rows=1000 width=xxx)
821
822 \o results/ut-R.tmpout
823 /*+Rows(v1t1 v1t1_ #1)*/
824 EXPLAIN SELECT * FROM s1.v1 t1, s1.v1_ t2 WHERE t1.c1 = t2.c1;
825 LOG:  pg_hint_plan:
826 used hint:
827 Rows(v1t1 v1t1_ #1)
828 not used hint:
829 duplication hint:
830 error hint:
831
832 \o
833 \! sql/maskout.sh results/ut-R.tmpout
834                                QUERY PLAN                                
835 -------------------------------------------------------------------------
836  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
837    Hash Cond: (v1t1.c1 = v1t1_.c1)
838    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
839    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
840          ->  Seq Scan on t1 v1t1_  (cost=xxx..xxx rows=1000 width=xxx)
841
842 -- No. R-1-6-11
843 \o results/ut-R.tmpout
844 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1 AND t1.c1 = (SELECT max(st1.c1) FROM s1.t1 st1, s1.t2 st2 WHERE st1.c1 = st2.c1);
845 \o
846 \! sql/maskout.sh results/ut-R.tmpout
847                                            QUERY PLAN                                            
848 -------------------------------------------------------------------------------------------------
849  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
850    InitPlan 1 (returns $0)
851      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
852            ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
853                  Merge Cond: (st1.c1 = st2.c1)
854                  ->  Index Only Scan using t1_i1 on t1 st1  (cost=xxx..xxx rows=1000 width=xxx)
855                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
856                        Sort Key: st2.c1
857                        ->  Seq Scan on t2 st2  (cost=xxx..xxx rows=100 width=xxx)
858    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
859          Index Cond: (c1 = $0)
860    ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
861          Filter: (c1 = $0)
862
863 \o results/ut-R.tmpout
864 /*+Rows(t1 t2 #1)Rows(st1 st2 #1)*/
865 EXPLAIN (COSTS true) SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1 AND t1.c1 = (SELECT max(st1.c1) FROM s1.t1 st1, s1.t2 st2 WHERE st1.c1 = st2.c1);
866 LOG:  pg_hint_plan:
867 used hint:
868 Rows(st1 st2 #1)
869 Rows(t1 t2 #1)
870 not used hint:
871 duplication hint:
872 error hint:
873
874 \o
875 \! sql/maskout.sh results/ut-R.tmpout
876                                            QUERY PLAN                                            
877 -------------------------------------------------------------------------------------------------
878  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
879    InitPlan 1 (returns $0)
880      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
881            ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
882                  Merge Cond: (st1.c1 = st2.c1)
883                  ->  Index Only Scan using t1_i1 on t1 st1  (cost=xxx..xxx rows=1000 width=xxx)
884                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
885                        Sort Key: st2.c1
886                        ->  Seq Scan on t2 st2  (cost=xxx..xxx rows=100 width=xxx)
887    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
888          Index Cond: (c1 = $0)
889    ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
890          Filter: (c1 = $0)
891
892 --
893 -- There are cases where difference in the measured value and predicted value
894 -- depending upon the version of PostgreSQL
895 --
896 \o results/ut-R.tmpout
897 EXPLAIN SELECT * FROM s1.t1, (SELECT t2.c1 FROM s1.t2) st2 WHERE t1.c1 = st2.c1;
898 \o
899 \! sql/maskout.sh results/ut-R.tmpout
900                                 QUERY PLAN                                 
901 ---------------------------------------------------------------------------
902  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
903    Merge Cond: (t1.c1 = t2.c1)
904    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
905    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
906          Sort Key: t2.c1
907          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
908
909 \o results/ut-R.tmpout
910 /*+Rows(t1 st2 #1)*/
911 EXPLAIN SELECT * FROM s1.t1, (SELECT t2.c1 FROM s1.t2) st2 WHERE t1.c1 = st2.c1;
912 LOG:  pg_hint_plan:
913 used hint:
914 not used hint:
915 Rows(st2 t1 #1)
916 duplication hint:
917 error hint:
918
919 \o
920 \! sql/maskout.sh results/ut-R.tmpout
921                                 QUERY PLAN                                 
922 ---------------------------------------------------------------------------
923  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
924    Merge Cond: (t1.c1 = t2.c1)
925    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
926    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
927          Sort Key: t2.c1
928          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
929
930 \o results/ut-R.tmpout
931 /*+Rows(t1 t2 #1)*/
932 EXPLAIN SELECT * FROM s1.t1, (SELECT t2.c1 FROM s1.t2) st2 WHERE t1.c1 = st2.c1;
933 LOG:  pg_hint_plan:
934 used hint:
935 Rows(t1 t2 #1)
936 not used hint:
937 duplication hint:
938 error hint:
939
940 \o
941 \! sql/maskout.sh results/ut-R.tmpout
942                                 QUERY PLAN                                 
943 ---------------------------------------------------------------------------
944  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
945    Merge Cond: (t1.c1 = t2.c1)
946    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
947    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
948          Sort Key: t2.c1
949          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
950
951 ----
952 ---- No. R-1-7 specified number of conditions
953 ----
954 -- No. R-1-7-1
955 \o results/ut-R.tmpout
956 /*+Rows(t1 #1)*/
957 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
958 INFO:  pg_hint_plan: hint syntax error at or near ""
959 DETAIL:  Rows hint requires at least two relations.
960 LOG:  pg_hint_plan:
961 used hint:
962 not used hint:
963 duplication hint:
964 error hint:
965 Rows(t1 #1)
966
967 \o
968 \! sql/maskout.sh results/ut-R.tmpout
969                                 QUERY PLAN                                 
970 ---------------------------------------------------------------------------
971  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
972    Merge Cond: (t1.c1 = t2.c1)
973    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
974    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
975          Sort Key: t2.c1
976          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
977
978 -- No. R-1-7-2
979 \o results/ut-R.tmpout
980 /*+Rows(t1 t2 1)*/
981 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
982 INFO:  pg_hint_plan: hint syntax error at or near "1"
983 DETAIL:  Unrecognized rows value type notation.
984 LOG:  pg_hint_plan:
985 used hint:
986 not used hint:
987 duplication hint:
988 error hint:
989 Rows(t1 t2 1)
990
991 \o
992 \! sql/maskout.sh results/ut-R.tmpout
993                                 QUERY PLAN                                 
994 ---------------------------------------------------------------------------
995  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
996    Merge Cond: (t1.c1 = t2.c1)
997    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
998    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
999          Sort Key: t2.c1
1000          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
1001
1002 -- No. R-1-7-3
1003 \o results/ut-R.tmpout
1004 /*+Rows(t1 t2 #notrows)*/
1005 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
1006 INFO:  pg_hint_plan: hint syntax error at or near "notrows"
1007 DETAIL:  Rows hint requires valid number as rows estimation.
1008 LOG:  pg_hint_plan:
1009 used hint:
1010 not used hint:
1011 duplication hint:
1012 error hint:
1013 Rows(t1 t2 #notrows)
1014
1015 \o
1016 \! sql/maskout.sh results/ut-R.tmpout
1017                                 QUERY PLAN                                 
1018 ---------------------------------------------------------------------------
1019  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1020    Merge Cond: (t1.c1 = t2.c1)
1021    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
1022    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1023          Sort Key: t2.c1
1024          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
1025
1026 ----
1027 ---- No. R-2-1 some complexity query blocks
1028 ----
1029 -- No. R-2-1-1
1030 \o results/ut-R.tmpout
1031 /*+
1032 Leading(bmt1 bmt2 bmt3 bmt4)
1033 Leading(b1t2 b1t3 b1t4 b1t1)
1034 Leading(b2t3 b2t4 b2t1 b2t2)
1035 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1036 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1037 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1038 */
1039 EXPLAIN
1040 SELECT max(bmt1.c1), (
1041 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1042 ), (
1043 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1044 )
1045                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1046 ;
1047 LOG:  pg_hint_plan:
1048 used hint:
1049 MergeJoin(b1t2 b1t3)
1050 MergeJoin(b2t3 b2t4)
1051 MergeJoin(bmt1 bmt2)
1052 HashJoin(b1t2 b1t3 b1t4)
1053 HashJoin(b2t1 b2t3 b2t4)
1054 HashJoin(bmt1 bmt2 bmt3)
1055 NestLoop(b1t1 b1t2 b1t3 b1t4)
1056 NestLoop(b2t1 b2t2 b2t3 b2t4)
1057 NestLoop(bmt1 bmt2 bmt3 bmt4)
1058 Leading(bmt1 bmt2 bmt3 bmt4)
1059 Leading(b1t2 b1t3 b1t4 b1t1)
1060 Leading(b2t3 b2t4 b2t1 b2t2)
1061 not used hint:
1062 duplication hint:
1063 error hint:
1064
1065 \o
1066 \! sql/maskout.sh results/ut-R.tmpout
1067                                                      QUERY PLAN                                                     
1068 --------------------------------------------------------------------------------------------------------------------
1069  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1070    InitPlan 1 (returns $1)
1071      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1072            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1073                  Join Filter: (b1t2.c1 = b1t1.c1)
1074                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1075                        Hash Cond: (b1t4.c1 = b1t2.c1)
1076                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1077                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1078                              ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1079                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1080                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1081                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1082                                          Sort Key: b1t2.c1
1083                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1084                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1085                        Index Cond: (c1 = b1t3.c1)
1086    InitPlan 2 (returns $3)
1087      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1088            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1089                  ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
1090                        Hash Cond: (b2t3.c1 = b2t1.c1)
1091                        ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
1092                              Merge Cond: (b2t3.c1 = b2t4.c1)
1093                              ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1094                              ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1095                        ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
1096                              ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1097                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1098                        Index Cond: (c1 = b2t1.c1)
1099    ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1100          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1101                Hash Cond: (bmt3.c1 = bmt1.c1)
1102                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1103                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1104                      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1105                            Merge Cond: (bmt1.c1 = bmt2.c1)
1106                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1107                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1108                                  Sort Key: bmt2.c1
1109                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1110          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1111                Index Cond: (c1 = bmt1.c1)
1112
1113 \o results/ut-R.tmpout
1114 /*+
1115 Leading(bmt1 bmt2 bmt3 bmt4)
1116 Leading(b1t2 b1t3 b1t4 b1t1)
1117 Leading(b2t3 b2t4 b2t1 b2t2)
1118 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1119 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1120 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1121 Rows(bmt1 bmt2 #1)Rows(bmt1 bmt2 bmt3 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1122 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
1123 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
1124 */
1125 EXPLAIN
1126 SELECT max(bmt1.c1), (
1127 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1128 ), (
1129 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1)
1130                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1131 ;
1132 LOG:  pg_hint_plan:
1133 used hint:
1134 MergeJoin(b1t2 b1t3)
1135 MergeJoin(b2t3 b2t4)
1136 MergeJoin(bmt1 bmt2)
1137 HashJoin(b1t2 b1t3 b1t4)
1138 HashJoin(b2t1 b2t3 b2t4)
1139 HashJoin(bmt1 bmt2 bmt3)
1140 NestLoop(b1t1 b1t2 b1t3 b1t4)
1141 NestLoop(b2t1 b2t2 b2t3 b2t4)
1142 NestLoop(bmt1 bmt2 bmt3 bmt4)
1143 Leading(bmt1 bmt2 bmt3 bmt4)
1144 Leading(b1t2 b1t3 b1t4 b1t1)
1145 Leading(b2t3 b2t4 b2t1 b2t2)
1146 Rows(b1t2 b1t3 #1)
1147 Rows(b2t3 b2t4 #1)
1148 Rows(bmt1 bmt2 #1)
1149 Rows(b1t2 b1t3 b1t4 #1)
1150 Rows(b2t1 b2t3 b2t4 #1)
1151 Rows(bmt1 bmt2 bmt3 #1)
1152 Rows(b1t1 b1t2 b1t3 b1t4 #1)
1153 Rows(b2t1 b2t2 b2t3 b2t4 #1)
1154 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1155 not used hint:
1156 duplication hint:
1157 error hint:
1158
1159 \o
1160 \! sql/maskout.sh results/ut-R.tmpout
1161                                                      QUERY PLAN                                                     
1162 --------------------------------------------------------------------------------------------------------------------
1163  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1164    InitPlan 1 (returns $1)
1165      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1166            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1167                  Join Filter: (b1t2.c1 = b1t1.c1)
1168                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1169                        Hash Cond: (b1t4.c1 = b1t2.c1)
1170                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1171                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1172                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1173                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1174                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1175                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1176                                          Sort Key: b1t2.c1
1177                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1178                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1179                        Index Cond: (c1 = b1t3.c1)
1180    InitPlan 2 (returns $3)
1181      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1182            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1183                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1184                        Hash Cond: (b2t1.c1 = b2t3.c1)
1185                        ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1186                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1187                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1188                                    Merge Cond: (b2t3.c1 = b2t4.c1)
1189                                    ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1190                                    ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1191                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1192                        Index Cond: (c1 = b2t1.c1)
1193    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1194          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1195                Hash Cond: (bmt3.c1 = bmt1.c1)
1196                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1197                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1198                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1199                            Merge Cond: (bmt1.c1 = bmt2.c1)
1200                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1201                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1202                                  Sort Key: bmt2.c1
1203                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1204          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1205                Index Cond: (c1 = bmt1.c1)
1206
1207 -- No. R-2-1-2
1208 \o results/ut-R.tmpout
1209 /*+
1210 Leading(bmt1 bmt2 bmt3 bmt4)
1211 Leading(b1t2 b1t3 b1t4 b1t1)
1212 Leading(b2t3 b2t4 b2t1 b2t2)
1213 Leading(b3t4 b3t1 b3t2 b3t3)
1214 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1215 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1216 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1217 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
1218 */
1219 EXPLAIN
1220 SELECT max(bmt1.c1), (
1221 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1222 ), (
1223 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1224 ), (
1225 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
1226 )
1227                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1228 ;
1229 LOG:  pg_hint_plan:
1230 used hint:
1231 MergeJoin(b1t2 b1t3)
1232 MergeJoin(b2t3 b2t4)
1233 MergeJoin(b3t1 b3t4)
1234 MergeJoin(bmt1 bmt2)
1235 HashJoin(b1t2 b1t3 b1t4)
1236 HashJoin(b2t1 b2t3 b2t4)
1237 HashJoin(b3t1 b3t2 b3t4)
1238 HashJoin(bmt1 bmt2 bmt3)
1239 NestLoop(b1t1 b1t2 b1t3 b1t4)
1240 NestLoop(b2t1 b2t2 b2t3 b2t4)
1241 NestLoop(b3t1 b3t2 b3t3 b3t4)
1242 NestLoop(bmt1 bmt2 bmt3 bmt4)
1243 Leading(bmt1 bmt2 bmt3 bmt4)
1244 Leading(b1t2 b1t3 b1t4 b1t1)
1245 Leading(b2t3 b2t4 b2t1 b2t2)
1246 Leading(b3t4 b3t1 b3t2 b3t3)
1247 not used hint:
1248 duplication hint:
1249 error hint:
1250
1251 \o
1252 \! sql/maskout.sh results/ut-R.tmpout
1253                                                      QUERY PLAN                                                     
1254 --------------------------------------------------------------------------------------------------------------------
1255  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1256    InitPlan 1 (returns $1)
1257      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1258            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1259                  Join Filter: (b1t2.c1 = b1t1.c1)
1260                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1261                        Hash Cond: (b1t4.c1 = b1t2.c1)
1262                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1263                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1264                              ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1265                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1266                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1267                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1268                                          Sort Key: b1t2.c1
1269                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1270                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1271                        Index Cond: (c1 = b1t3.c1)
1272    InitPlan 2 (returns $3)
1273      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1274            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1275                  ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
1276                        Hash Cond: (b2t3.c1 = b2t1.c1)
1277                        ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
1278                              Merge Cond: (b2t3.c1 = b2t4.c1)
1279                              ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1280                              ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1281                        ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
1282                              ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1283                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1284                        Index Cond: (c1 = b2t1.c1)
1285    InitPlan 3 (returns $5)
1286      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1287            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1288                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1289                        Hash Cond: (b3t1.c1 = b3t2.c1)
1290                        ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
1291                              Merge Cond: (b3t1.c1 = b3t4.c1)
1292                              ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
1293                              ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
1294                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1295                              ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
1296                  ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
1297                        Index Cond: (c1 = b3t1.c1)
1298    ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1299          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1300                Hash Cond: (bmt3.c1 = bmt1.c1)
1301                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1302                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1303                      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1304                            Merge Cond: (bmt1.c1 = bmt2.c1)
1305                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1306                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1307                                  Sort Key: bmt2.c1
1308                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1309          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1310                Index Cond: (c1 = bmt1.c1)
1311
1312 \o results/ut-R.tmpout
1313 /*+
1314 Leading(bmt1 bmt2 bmt3 bmt4)
1315 Leading(b1t2 b1t3 b1t4 b1t1)
1316 Leading(b2t3 b2t4 b2t1 b2t2)
1317 Leading(b3t4 b3t1 b3t2 b3t3)
1318 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1319 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1320 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1321 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
1322 Rows(bmt1 bmt2 #1)Rows(bmt1 bmt2 bmt3 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1323 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
1324 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
1325 Rows(b3t4 b3t1 #1)Rows(b3t4 b3t1 b3t2 #1)Rows(b3t1 b3t2 b3t3 b3t4 #1)
1326 */
1327 EXPLAIN
1328 SELECT max(bmt1.c1), (
1329 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1330 ), (
1331 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1332 ), (
1333 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
1334 )
1335                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1336 ;
1337 LOG:  pg_hint_plan:
1338 used hint:
1339 MergeJoin(b1t2 b1t3)
1340 MergeJoin(b2t3 b2t4)
1341 MergeJoin(b3t1 b3t4)
1342 MergeJoin(bmt1 bmt2)
1343 HashJoin(b1t2 b1t3 b1t4)
1344 HashJoin(b2t1 b2t3 b2t4)
1345 HashJoin(b3t1 b3t2 b3t4)
1346 HashJoin(bmt1 bmt2 bmt3)
1347 NestLoop(b1t1 b1t2 b1t3 b1t4)
1348 NestLoop(b2t1 b2t2 b2t3 b2t4)
1349 NestLoop(b3t1 b3t2 b3t3 b3t4)
1350 NestLoop(bmt1 bmt2 bmt3 bmt4)
1351 Leading(bmt1 bmt2 bmt3 bmt4)
1352 Leading(b1t2 b1t3 b1t4 b1t1)
1353 Leading(b2t3 b2t4 b2t1 b2t2)
1354 Leading(b3t4 b3t1 b3t2 b3t3)
1355 Rows(b1t2 b1t3 #1)
1356 Rows(b2t3 b2t4 #1)
1357 Rows(b3t1 b3t4 #1)
1358 Rows(bmt1 bmt2 #1)
1359 Rows(b1t2 b1t3 b1t4 #1)
1360 Rows(b2t1 b2t3 b2t4 #1)
1361 Rows(b3t1 b3t2 b3t4 #1)
1362 Rows(bmt1 bmt2 bmt3 #1)
1363 Rows(b1t1 b1t2 b1t3 b1t4 #1)
1364 Rows(b2t1 b2t2 b2t3 b2t4 #1)
1365 Rows(b3t1 b3t2 b3t3 b3t4 #1)
1366 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1367 not used hint:
1368 duplication hint:
1369 error hint:
1370
1371 \o
1372 \! sql/maskout.sh results/ut-R.tmpout
1373                                                      QUERY PLAN                                                     
1374 --------------------------------------------------------------------------------------------------------------------
1375  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1376    InitPlan 1 (returns $1)
1377      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1378            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1379                  Join Filter: (b1t2.c1 = b1t1.c1)
1380                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1381                        Hash Cond: (b1t4.c1 = b1t2.c1)
1382                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1383                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1384                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1385                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1386                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1387                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1388                                          Sort Key: b1t2.c1
1389                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1390                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1391                        Index Cond: (c1 = b1t3.c1)
1392    InitPlan 2 (returns $3)
1393      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1394            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1395                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1396                        Hash Cond: (b2t1.c1 = b2t3.c1)
1397                        ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1398                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1399                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1400                                    Merge Cond: (b2t3.c1 = b2t4.c1)
1401                                    ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1402                                    ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1403                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1404                        Index Cond: (c1 = b2t1.c1)
1405    InitPlan 3 (returns $5)
1406      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1407            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1408                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1409                        Hash Cond: (b3t1.c1 = b3t2.c1)
1410                        ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1411                              Merge Cond: (b3t1.c1 = b3t4.c1)
1412                              ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
1413                              ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
1414                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1415                              ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
1416                  ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
1417                        Index Cond: (c1 = b3t1.c1)
1418    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1419          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1420                Hash Cond: (bmt3.c1 = bmt1.c1)
1421                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1422                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1423                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1424                            Merge Cond: (bmt1.c1 = bmt2.c1)
1425                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1426                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1427                                  Sort Key: bmt2.c1
1428                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1429          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1430                Index Cond: (c1 = bmt1.c1)
1431
1432 -- No. R-2-1-3
1433 \o results/ut-R.tmpout
1434 /*+
1435 Leading(bmt4 bmt3 bmt2 bmt1)
1436 */
1437 EXPLAIN SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
1438 LOG:  pg_hint_plan:
1439 used hint:
1440 Leading(bmt4 bmt3 bmt2 bmt1)
1441 not used hint:
1442 duplication hint:
1443 error hint:
1444
1445 \o
1446 \! sql/maskout.sh results/ut-R.tmpout
1447                                           QUERY PLAN                                           
1448 -----------------------------------------------------------------------------------------------
1449  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1450    ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1451          Merge Cond: (bmt1.c1 = bmt2.c1)
1452          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1453          ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1454                Sort Key: bmt2.c1
1455                ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1456                      Hash Cond: (bmt3.c1 = bmt2.c1)
1457                      ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
1458                            Hash Cond: (bmt3.c1 = bmt4.c1)
1459                            ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1460                            ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
1461                                  ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
1462                      ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1463                            ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1464
1465 \o results/ut-R.tmpout
1466 /*+
1467 Leading(bmt4 bmt3 bmt2 bmt1)
1468 Rows(bmt4 bmt3 #1)Rows(bmt4 bmt3 bmt2 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1469 */
1470 EXPLAIN SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
1471 LOG:  pg_hint_plan:
1472 used hint:
1473 Leading(bmt4 bmt3 bmt2 bmt1)
1474 Rows(bmt3 bmt4 #1)
1475 Rows(bmt2 bmt3 bmt4 #1)
1476 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1477 not used hint:
1478 duplication hint:
1479 error hint:
1480
1481 \o
1482 \! sql/maskout.sh results/ut-R.tmpout
1483                                          QUERY PLAN                                         
1484 --------------------------------------------------------------------------------------------
1485  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1486    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1487          Join Filter: (bmt2.c1 = bmt1.c1)
1488          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1489                ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1490                      Hash Cond: (bmt3.c1 = bmt4.c1)
1491                      ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1492                      ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
1493                            ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
1494                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
1495                      Index Cond: (c1 = bmt3.c1)
1496          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
1497                Index Cond: (c1 = bmt3.c1)
1498
1499 -- No. R-2-1-4
1500 \o results/ut-R.tmpout
1501 /*+
1502 Leading(bmt4 bmt3 bmt2 bmt1)
1503 */
1504 EXPLAIN SELECT max(bmt1.c1) FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
1505 LOG:  pg_hint_plan:
1506 used hint:
1507 Leading(bmt4 bmt3 bmt2 bmt1)
1508 not used hint:
1509 duplication hint:
1510 error hint:
1511
1512 \o
1513 \! sql/maskout.sh results/ut-R.tmpout
1514                                           QUERY PLAN                                           
1515 -----------------------------------------------------------------------------------------------
1516  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1517    ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1518          Merge Cond: (bmt1.c1 = bmt2.c1)
1519          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
1520          ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1521                Sort Key: bmt2.c1
1522                ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1523                      Hash Cond: (bmt3.c1 = bmt2.c1)
1524                      ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
1525                            Hash Cond: (bmt3.c1 = bmt4.c1)
1526                            ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1527                            ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
1528                                  ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
1529                      ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1530                            ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1531
1532 \o results/ut-R.tmpout
1533 /*+
1534 Leading(bmt4 bmt3 bmt2 bmt1)
1535 Rows(bmt4 bmt3 #1)Rows(bmt4 bmt3 bmt2 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1536 */
1537 EXPLAIN SELECT max(bmt1.c1) FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
1538 LOG:  pg_hint_plan:
1539 used hint:
1540 Leading(bmt4 bmt3 bmt2 bmt1)
1541 Rows(bmt3 bmt4 #1)
1542 Rows(bmt2 bmt3 bmt4 #1)
1543 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1544 not used hint:
1545 duplication hint:
1546 error hint:
1547
1548 \o
1549 \! sql/maskout.sh results/ut-R.tmpout
1550                                          QUERY PLAN                                         
1551 --------------------------------------------------------------------------------------------
1552  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1553    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1554          Join Filter: (bmt2.c1 = bmt1.c1)
1555          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1556                ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1557                      Hash Cond: (bmt3.c1 = bmt4.c1)
1558                      ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1559                      ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
1560                            ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
1561                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
1562                      Index Cond: (c1 = bmt3.c1)
1563          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
1564                Index Cond: (c1 = bmt3.c1)
1565
1566 -- No. R-2-1-5
1567 \o results/ut-R.tmpout
1568 /*+
1569 Leading(bmt1 bmt2 bmt3 bmt4)
1570 Leading(b1t2 b1t3 b1t4 b1t1)
1571 Leading(b2t3 b2t4 b2t1 b2t2)
1572 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1573 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1574 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1575 */
1576 EXPLAIN
1577 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1578 AND bmt1.c1 <> (
1579 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1580 ) AND bmt1.c1 <> (
1581 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1582 );
1583 LOG:  pg_hint_plan:
1584 used hint:
1585 MergeJoin(b1t2 b1t3)
1586 MergeJoin(b2t3 b2t4)
1587 MergeJoin(bmt1 bmt2)
1588 HashJoin(b1t2 b1t3 b1t4)
1589 HashJoin(b2t1 b2t3 b2t4)
1590 HashJoin(bmt1 bmt2 bmt3)
1591 NestLoop(b1t1 b1t2 b1t3 b1t4)
1592 NestLoop(b2t1 b2t2 b2t3 b2t4)
1593 NestLoop(bmt1 bmt2 bmt3 bmt4)
1594 Leading(bmt1 bmt2 bmt3 bmt4)
1595 Leading(b1t2 b1t3 b1t4 b1t1)
1596 Leading(b2t3 b2t4 b2t1 b2t2)
1597 not used hint:
1598 duplication hint:
1599 error hint:
1600
1601 \o
1602 \! sql/maskout.sh results/ut-R.tmpout
1603                                                      QUERY PLAN                                                     
1604 --------------------------------------------------------------------------------------------------------------------
1605  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1606    InitPlan 1 (returns $1)
1607      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1608            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1609                  Join Filter: (b1t2.c1 = b1t1.c1)
1610                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1611                        Hash Cond: (b1t4.c1 = b1t2.c1)
1612                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1613                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1614                              ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1615                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1616                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1617                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1618                                          Sort Key: b1t2.c1
1619                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1620                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1621                        Index Cond: (c1 = b1t3.c1)
1622    InitPlan 2 (returns $3)
1623      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1624            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1625                  ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
1626                        Hash Cond: (b2t3.c1 = b2t1.c1)
1627                        ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
1628                              Merge Cond: (b2t3.c1 = b2t4.c1)
1629                              ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1630                              ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1631                        ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
1632                              ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1633                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1634                        Index Cond: (c1 = b2t1.c1)
1635    ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1636          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1637                Hash Cond: (bmt3.c1 = bmt1.c1)
1638                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1639                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1640                      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1641                            Merge Cond: (bmt1.c1 = bmt2.c1)
1642                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=998 width=xxx)
1643                                  Filter: ((c1 <> $1) AND (c1 <> $3))
1644                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1645                                  Sort Key: bmt2.c1
1646                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1647          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1648                Index Cond: (c1 = bmt1.c1)
1649
1650 \o results/ut-R.tmpout
1651 /*+
1652 Leading(bmt1 bmt2 bmt3 bmt4)
1653 Leading(b1t2 b1t3 b1t4 b1t1)
1654 Leading(b2t3 b2t4 b2t1 b2t2)
1655 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1656 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1657 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1658 Rows(bmt1 bmt2 #1)Rows(bmt1 bmt2 bmt3 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1659 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
1660 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
1661 */
1662 EXPLAIN
1663 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1664 AND bmt1.c1 <> (
1665 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1666 ) AND bmt1.c1 <> (
1667 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1668 )
1669 ;
1670 LOG:  pg_hint_plan:
1671 used hint:
1672 MergeJoin(b1t2 b1t3)
1673 MergeJoin(b2t3 b2t4)
1674 MergeJoin(bmt1 bmt2)
1675 HashJoin(b1t2 b1t3 b1t4)
1676 HashJoin(b2t1 b2t3 b2t4)
1677 HashJoin(bmt1 bmt2 bmt3)
1678 NestLoop(b1t1 b1t2 b1t3 b1t4)
1679 NestLoop(b2t1 b2t2 b2t3 b2t4)
1680 NestLoop(bmt1 bmt2 bmt3 bmt4)
1681 Leading(bmt1 bmt2 bmt3 bmt4)
1682 Leading(b1t2 b1t3 b1t4 b1t1)
1683 Leading(b2t3 b2t4 b2t1 b2t2)
1684 Rows(b1t2 b1t3 #1)
1685 Rows(b2t3 b2t4 #1)
1686 Rows(bmt1 bmt2 #1)
1687 Rows(b1t2 b1t3 b1t4 #1)
1688 Rows(b2t1 b2t3 b2t4 #1)
1689 Rows(bmt1 bmt2 bmt3 #1)
1690 Rows(b1t1 b1t2 b1t3 b1t4 #1)
1691 Rows(b2t1 b2t2 b2t3 b2t4 #1)
1692 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1693 not used hint:
1694 duplication hint:
1695 error hint:
1696
1697 \o
1698 \! sql/maskout.sh results/ut-R.tmpout
1699                                                      QUERY PLAN                                                     
1700 --------------------------------------------------------------------------------------------------------------------
1701  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1702    InitPlan 1 (returns $1)
1703      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1704            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1705                  Join Filter: (b1t2.c1 = b1t1.c1)
1706                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1707                        Hash Cond: (b1t4.c1 = b1t2.c1)
1708                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1709                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1710                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1711                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1712                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1713                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1714                                          Sort Key: b1t2.c1
1715                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1716                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1717                        Index Cond: (c1 = b1t3.c1)
1718    InitPlan 2 (returns $3)
1719      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1720            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1721                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1722                        Hash Cond: (b2t1.c1 = b2t3.c1)
1723                        ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1724                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1725                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1726                                    Merge Cond: (b2t3.c1 = b2t4.c1)
1727                                    ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1728                                    ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1729                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1730                        Index Cond: (c1 = b2t1.c1)
1731    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1732          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1733                Hash Cond: (bmt3.c1 = bmt1.c1)
1734                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1735                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1736                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1737                            Merge Cond: (bmt1.c1 = bmt2.c1)
1738                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=998 width=xxx)
1739                                  Filter: ((c1 <> $1) AND (c1 <> $3))
1740                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1741                                  Sort Key: bmt2.c1
1742                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1743          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1744                Index Cond: (c1 = bmt1.c1)
1745
1746 -- No. R-2-1-6
1747 \o results/ut-R.tmpout
1748 /*+
1749 Leading(bmt1 bmt2 bmt3 bmt4)
1750 Leading(b1t2 b1t3 b1t4 b1t1)
1751 Leading(b2t3 b2t4 b2t1 b2t2)
1752 Leading(b3t4 b3t1 b3t2 b3t3)
1753 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1754 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1755 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1756 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
1757 */
1758 EXPLAIN
1759 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1760   AND bmt1.c1 <> (
1761 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1762 ) AND bmt1.c1 <> (
1763 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1764 ) AND bmt1.c1 <> (
1765 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
1766 )
1767 ;
1768 LOG:  pg_hint_plan:
1769 used hint:
1770 MergeJoin(b1t2 b1t3)
1771 MergeJoin(b2t3 b2t4)
1772 MergeJoin(b3t1 b3t4)
1773 MergeJoin(bmt1 bmt2)
1774 HashJoin(b1t2 b1t3 b1t4)
1775 HashJoin(b2t1 b2t3 b2t4)
1776 HashJoin(b3t1 b3t2 b3t4)
1777 HashJoin(bmt1 bmt2 bmt3)
1778 NestLoop(b1t1 b1t2 b1t3 b1t4)
1779 NestLoop(b2t1 b2t2 b2t3 b2t4)
1780 NestLoop(b3t1 b3t2 b3t3 b3t4)
1781 NestLoop(bmt1 bmt2 bmt3 bmt4)
1782 Leading(bmt1 bmt2 bmt3 bmt4)
1783 Leading(b1t2 b1t3 b1t4 b1t1)
1784 Leading(b2t3 b2t4 b2t1 b2t2)
1785 Leading(b3t4 b3t1 b3t2 b3t3)
1786 not used hint:
1787 duplication hint:
1788 error hint:
1789
1790 \o
1791 \! sql/maskout.sh results/ut-R.tmpout
1792                                                      QUERY PLAN                                                     
1793 --------------------------------------------------------------------------------------------------------------------
1794  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1795    InitPlan 1 (returns $1)
1796      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1797            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1798                  Join Filter: (b1t2.c1 = b1t1.c1)
1799                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1800                        Hash Cond: (b1t4.c1 = b1t2.c1)
1801                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1802                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1803                              ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1804                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1805                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1806                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1807                                          Sort Key: b1t2.c1
1808                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1809                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1810                        Index Cond: (c1 = b1t3.c1)
1811    InitPlan 2 (returns $3)
1812      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1813            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1814                  ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
1815                        Hash Cond: (b2t3.c1 = b2t1.c1)
1816                        ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
1817                              Merge Cond: (b2t3.c1 = b2t4.c1)
1818                              ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1819                              ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1820                        ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
1821                              ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1822                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1823                        Index Cond: (c1 = b2t1.c1)
1824    InitPlan 3 (returns $5)
1825      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1826            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1827                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1828                        Hash Cond: (b3t1.c1 = b3t2.c1)
1829                        ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
1830                              Merge Cond: (b3t1.c1 = b3t4.c1)
1831                              ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
1832                              ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
1833                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1834                              ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
1835                  ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
1836                        Index Cond: (c1 = b3t1.c1)
1837    ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
1838          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
1839                Hash Cond: (bmt3.c1 = bmt1.c1)
1840                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1841                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1842                      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
1843                            Merge Cond: (bmt1.c1 = bmt2.c1)
1844                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=997 width=xxx)
1845                                  Filter: ((c1 <> $1) AND (c1 <> $3) AND (c1 <> $5))
1846                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1847                                  Sort Key: bmt2.c1
1848                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1849          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1850                Index Cond: (c1 = bmt1.c1)
1851
1852 \o results/ut-R.tmpout
1853 /*+
1854 Leading(bmt1 bmt2 bmt3 bmt4)
1855 Leading(b1t2 b1t3 b1t4 b1t1)
1856 Leading(b2t3 b2t4 b2t1 b2t2)
1857 Leading(b3t4 b3t1 b3t2 b3t3)
1858 MergeJoin(bmt1 bmt2)HashJoin(bmt1 bmt2 bmt3)NestLoop(bmt1 bmt2 bmt3 bmt4)
1859 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1860 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1861 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
1862 Rows(bmt1 bmt2 #1)Rows(bmt1 bmt2 bmt3 #1)Rows(bmt1 bmt2 bmt3 bmt4 #1)
1863 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
1864 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
1865 Rows(b3t4 b3t1 #1)Rows(b3t4 b3t1 b3t2 #1)Rows(b3t1 b3t2 b3t3 b3t4 #1)
1866 */
1867 EXPLAIN
1868 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1869   AND bmt1.c1 <> (
1870 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1871 ) AND bmt1.c1 <> (
1872 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1873 ) AND bmt1.c1 <> (
1874 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
1875 )
1876 ;
1877 LOG:  pg_hint_plan:
1878 used hint:
1879 MergeJoin(b1t2 b1t3)
1880 MergeJoin(b2t3 b2t4)
1881 MergeJoin(b3t1 b3t4)
1882 MergeJoin(bmt1 bmt2)
1883 HashJoin(b1t2 b1t3 b1t4)
1884 HashJoin(b2t1 b2t3 b2t4)
1885 HashJoin(b3t1 b3t2 b3t4)
1886 HashJoin(bmt1 bmt2 bmt3)
1887 NestLoop(b1t1 b1t2 b1t3 b1t4)
1888 NestLoop(b2t1 b2t2 b2t3 b2t4)
1889 NestLoop(b3t1 b3t2 b3t3 b3t4)
1890 NestLoop(bmt1 bmt2 bmt3 bmt4)
1891 Leading(bmt1 bmt2 bmt3 bmt4)
1892 Leading(b1t2 b1t3 b1t4 b1t1)
1893 Leading(b2t3 b2t4 b2t1 b2t2)
1894 Leading(b3t4 b3t1 b3t2 b3t3)
1895 Rows(b1t2 b1t3 #1)
1896 Rows(b2t3 b2t4 #1)
1897 Rows(b3t1 b3t4 #1)
1898 Rows(bmt1 bmt2 #1)
1899 Rows(b1t2 b1t3 b1t4 #1)
1900 Rows(b2t1 b2t3 b2t4 #1)
1901 Rows(b3t1 b3t2 b3t4 #1)
1902 Rows(bmt1 bmt2 bmt3 #1)
1903 Rows(b1t1 b1t2 b1t3 b1t4 #1)
1904 Rows(b2t1 b2t2 b2t3 b2t4 #1)
1905 Rows(b3t1 b3t2 b3t3 b3t4 #1)
1906 Rows(bmt1 bmt2 bmt3 bmt4 #1)
1907 not used hint:
1908 duplication hint:
1909 error hint:
1910
1911 \o
1912 \! sql/maskout.sh results/ut-R.tmpout
1913                                                      QUERY PLAN                                                     
1914 --------------------------------------------------------------------------------------------------------------------
1915  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1916    InitPlan 1 (returns $1)
1917      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1918            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1919                  Join Filter: (b1t2.c1 = b1t1.c1)
1920                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1921                        Hash Cond: (b1t4.c1 = b1t2.c1)
1922                        ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
1923                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1924                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1925                                    Merge Cond: (b1t3.c1 = b1t2.c1)
1926                                    ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
1927                                    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1928                                          Sort Key: b1t2.c1
1929                                          ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
1930                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
1931                        Index Cond: (c1 = b1t3.c1)
1932    InitPlan 2 (returns $3)
1933      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1934            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1935                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1936                        Hash Cond: (b2t1.c1 = b2t3.c1)
1937                        ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
1938                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1939                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1940                                    Merge Cond: (b2t3.c1 = b2t4.c1)
1941                                    ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
1942                                    ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
1943                  ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
1944                        Index Cond: (c1 = b2t1.c1)
1945    InitPlan 3 (returns $5)
1946      ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
1947            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1948                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1949                        Hash Cond: (b3t1.c1 = b3t2.c1)
1950                        ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1951                              Merge Cond: (b3t1.c1 = b3t4.c1)
1952                              ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
1953                              ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
1954                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
1955                              ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
1956                  ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
1957                        Index Cond: (c1 = b3t1.c1)
1958    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
1959          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
1960                Hash Cond: (bmt3.c1 = bmt1.c1)
1961                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
1962                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
1963                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
1964                            Merge Cond: (bmt1.c1 = bmt2.c1)
1965                            ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=997 width=xxx)
1966                                  Filter: ((c1 <> $1) AND (c1 <> $3) AND (c1 <> $5))
1967                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
1968                                  Sort Key: bmt2.c1
1969                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
1970          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
1971                Index Cond: (c1 = bmt1.c1)
1972
1973 -- No. R-2-1-7
1974 \o results/ut-R.tmpout
1975 /*+
1976 Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
1977 Leading(b1t2 b1t3 b1t4 b1t1)
1978 Leading(b2t3 b2t4 b2t1 b2t2)
1979 MergeJoin(c2 c1)HashJoin(c2 c1 bmt1)NestLoop(c2 c1 bmt1 bmt2)MergeJoin(c2 c1 bmt1 bmt2 bmt3)HashJoin(c2 c1 bmt1 bmt2 bmt3 bmt4)
1980 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
1981 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
1982 */
1983 EXPLAIN
1984 WITH c1 (c1) AS (
1985 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
1986 )
1987 , c2 (c1) AS (
1988 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
1989 )
1990 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4
1991 , c1, c2
1992                                                                         WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
1993 AND bmt1.c1 = c1.c1
1994 AND bmt1.c1 = c2.c1
1995 ;
1996 LOG:  pg_hint_plan:
1997 used hint:
1998 MergeJoin(b1t2 b1t3)
1999 MergeJoin(b2t3 b2t4)
2000 MergeJoin(c1 c2)
2001 HashJoin(b1t2 b1t3 b1t4)
2002 HashJoin(b2t1 b2t3 b2t4)
2003 HashJoin(bmt1 c1 c2)
2004 NestLoop(b1t1 b1t2 b1t3 b1t4)
2005 NestLoop(b2t1 b2t2 b2t3 b2t4)
2006 NestLoop(bmt1 bmt2 c1 c2)
2007 MergeJoin(bmt1 bmt2 bmt3 c1 c2)
2008 HashJoin(bmt1 bmt2 bmt3 bmt4 c1 c2)
2009 Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
2010 Leading(b1t2 b1t3 b1t4 b1t1)
2011 Leading(b2t3 b2t4 b2t1 b2t2)
2012 not used hint:
2013 duplication hint:
2014 error hint:
2015
2016 \o
2017 \! sql/maskout.sh results/ut-R.tmpout
2018                                                                                QUERY PLAN                                                                               
2019 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2020  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2021    ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2022          Hash Cond: (bmt4.c1 = bmt1.c1)
2023          ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
2024          ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2025                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2026                      Merge Cond: (bmt3.c1 = bmt1.c1)
2027                      ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
2028                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2029                            Sort Key: bmt1.c1
2030                            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2031                                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2032                                        Hash Cond: (bmt1.c1 = (max(b1t1.c1)))
2033                                        ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
2034                                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2035                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2036                                                    Merge Cond: ((max(b1t1.c1)) = (max(b2t1.c1)))
2037                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2038                                                          Sort Key: (max(b1t1.c1))
2039                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2040                                                                ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2041                                                                      Join Filter: (b1t2.c1 = b1t1.c1)
2042                                                                      ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
2043                                                                            Hash Cond: (b1t4.c1 = b1t2.c1)
2044                                                                            ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2045                                                                            ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
2046                                                                                  ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2047                                                                                        Merge Cond: (b1t3.c1 = b1t2.c1)
2048                                                                                        ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2049                                                                                        ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2050                                                                                              Sort Key: b1t2.c1
2051                                                                                              ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2052                                                                      ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2053                                                                            Index Cond: (c1 = b1t3.c1)
2054                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2055                                                          Sort Key: (max(b2t1.c1))
2056                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2057                                                                ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2058                                                                      ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
2059                                                                            Hash Cond: (b2t3.c1 = b2t1.c1)
2060                                                                            ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
2061                                                                                  Merge Cond: (b2t3.c1 = b2t4.c1)
2062                                                                                  ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2063                                                                                  ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2064                                                                            ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
2065                                                                                  ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2066                                                                      ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2067                                                                            Index Cond: (c1 = b2t1.c1)
2068                                  ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2069                                        Index Cond: (c1 = bmt1.c1)
2070
2071 \o results/ut-R.tmpout
2072 /*+
2073 Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
2074 Leading(b1t2 b1t3 b1t4 b1t1)
2075 Leading(b2t3 b2t4 b2t1 b2t2)
2076 MergeJoin(c2 c1)HashJoin(c2 c1 bmt1)NestLoop(c2 c1 bmt1 bmt2)MergeJoin(c2 c1 bmt1 bmt2 bmt3)HashJoin(c2 c1 bmt1 bmt2 bmt3 bmt4)
2077 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
2078 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
2079 Rows(c2 c1 #1)Rows(c2 c1 bmt1 #1)Rows(c2 c1 bmt1 bmt2 #1)Rows(c2 c1 bmt1 bmt2 bmt3 #1)Rows(c2 c1 bmt1 bmt2 bmt3 bmt4 #1)
2080 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
2081 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
2082 */
2083 EXPLAIN
2084 WITH c1 (c1) AS (
2085 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2086 )
2087 , c2 (c1) AS (
2088 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
2089 )
2090 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4
2091 , c1, c2
2092                                                                         WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
2093 AND bmt1.c1 = c1.c1
2094 AND bmt1.c1 = c2.c1;
2095 LOG:  pg_hint_plan:
2096 used hint:
2097 MergeJoin(b1t2 b1t3)
2098 MergeJoin(b2t3 b2t4)
2099 MergeJoin(c1 c2)
2100 HashJoin(b1t2 b1t3 b1t4)
2101 HashJoin(b2t1 b2t3 b2t4)
2102 HashJoin(bmt1 c1 c2)
2103 NestLoop(b1t1 b1t2 b1t3 b1t4)
2104 NestLoop(b2t1 b2t2 b2t3 b2t4)
2105 NestLoop(bmt1 bmt2 c1 c2)
2106 MergeJoin(bmt1 bmt2 bmt3 c1 c2)
2107 HashJoin(bmt1 bmt2 bmt3 bmt4 c1 c2)
2108 Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
2109 Leading(b1t2 b1t3 b1t4 b1t1)
2110 Leading(b2t3 b2t4 b2t1 b2t2)
2111 Rows(b1t2 b1t3 #1)
2112 Rows(b2t3 b2t4 #1)
2113 Rows(c1 c2 #1)
2114 Rows(b1t2 b1t3 b1t4 #1)
2115 Rows(b2t1 b2t3 b2t4 #1)
2116 Rows(bmt1 c1 c2 #1)
2117 Rows(b1t1 b1t2 b1t3 b1t4 #1)
2118 Rows(b2t1 b2t2 b2t3 b2t4 #1)
2119 Rows(bmt1 bmt2 c1 c2 #1)
2120 Rows(bmt1 bmt2 bmt3 c1 c2 #1)
2121 Rows(bmt1 bmt2 bmt3 bmt4 c1 c2 #1)
2122 not used hint:
2123 duplication hint:
2124 error hint:
2125
2126 \o
2127 \! sql/maskout.sh results/ut-R.tmpout
2128                                                                                QUERY PLAN                                                                               
2129 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2130  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2131    ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2132          Hash Cond: (bmt4.c1 = bmt1.c1)
2133          ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
2134          ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2135                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2136                      Merge Cond: (bmt3.c1 = bmt1.c1)
2137                      ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
2138                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2139                            Sort Key: bmt1.c1
2140                            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2141                                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2142                                        Hash Cond: (bmt1.c1 = (max(b1t1.c1)))
2143                                        ->  Seq Scan on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
2144                                        ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2145                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2146                                                    Merge Cond: ((max(b1t1.c1)) = (max(b2t1.c1)))
2147                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2148                                                          Sort Key: (max(b1t1.c1))
2149                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2150                                                                ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2151                                                                      Join Filter: (b1t2.c1 = b1t1.c1)
2152                                                                      ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2153                                                                            Hash Cond: (b1t4.c1 = b1t2.c1)
2154                                                                            ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2155                                                                            ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2156                                                                                  ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2157                                                                                        Merge Cond: (b1t3.c1 = b1t2.c1)
2158                                                                                        ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2159                                                                                        ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2160                                                                                              Sort Key: b1t2.c1
2161                                                                                              ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2162                                                                      ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2163                                                                            Index Cond: (c1 = b1t3.c1)
2164                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2165                                                          Sort Key: (max(b2t1.c1))
2166                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2167                                                                ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2168                                                                      ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2169                                                                            Hash Cond: (b2t1.c1 = b2t3.c1)
2170                                                                            ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2171                                                                            ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2172                                                                                  ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2173                                                                                        Merge Cond: (b2t3.c1 = b2t4.c1)
2174                                                                                        ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2175                                                                                        ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2176                                                                      ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2177                                                                            Index Cond: (c1 = b2t1.c1)
2178                                  ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2179                                        Index Cond: (c1 = bmt1.c1)
2180
2181 -- No. R-2-1-8
2182 \o results/ut-R.tmpout
2183 /*+
2184 Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2185 Leading(b1t2 b1t3 b1t4 b1t1)
2186 Leading(b2t3 b2t4 b2t1 b2t2)
2187 Leading(b3t4 b3t1 b3t2 b3t3)
2188 MergeJoin(c3 c2)HashJoin(c3 c2 c1)NestLoop(c3 c2 c1 bmt1)MergeJoin(c3 c2 c1 bmt1 bmt2)HashJoin(c3 c2 c1 bmt1 bmt2 bmt3)NestLoop(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2189 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
2190 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
2191 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
2192 */
2193 EXPLAIN
2194 WITH c1 (c1) AS (
2195 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2196 )
2197 , c2 (c1) AS (
2198 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
2199 )
2200 , c3 (c1) AS (
2201 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
2202 )
2203 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4
2204 , c1, c2, c3
2205                                                                         WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
2206 AND bmt1.c1 = c1.c1
2207 AND bmt1.c1 = c2.c1
2208 AND bmt1.c1 = c3.c1;
2209 LOG:  pg_hint_plan:
2210 used hint:
2211 MergeJoin(b1t2 b1t3)
2212 MergeJoin(b2t3 b2t4)
2213 MergeJoin(b3t1 b3t4)
2214 MergeJoin(c2 c3)
2215 HashJoin(b1t2 b1t3 b1t4)
2216 HashJoin(b2t1 b2t3 b2t4)
2217 HashJoin(b3t1 b3t2 b3t4)
2218 HashJoin(c1 c2 c3)
2219 NestLoop(b1t1 b1t2 b1t3 b1t4)
2220 NestLoop(b2t1 b2t2 b2t3 b2t4)
2221 NestLoop(b3t1 b3t2 b3t3 b3t4)
2222 NestLoop(bmt1 c1 c2 c3)
2223 MergeJoin(bmt1 bmt2 c1 c2 c3)
2224 HashJoin(bmt1 bmt2 bmt3 c1 c2 c3)
2225 NestLoop(bmt1 bmt2 bmt3 bmt4 c1 c2 c3)
2226 Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2227 Leading(b1t2 b1t3 b1t4 b1t1)
2228 Leading(b2t3 b2t4 b2t1 b2t2)
2229 Leading(b3t4 b3t1 b3t2 b3t3)
2230 not used hint:
2231 duplication hint:
2232 error hint:
2233
2234 \o
2235 \! sql/maskout.sh results/ut-R.tmpout
2236                                                                             QUERY PLAN                                                                            
2237 ------------------------------------------------------------------------------------------------------------------------------------------------------------------
2238  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2239    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2240          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2241                Hash Cond: (bmt3.c1 = bmt1.c1)
2242                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
2243                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2244                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2245                            Merge Cond: (bmt1.c1 = bmt2.c1)
2246                            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2247                                  Sort Key: bmt1.c1
2248                                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2249                                        Join Filter: ((max(b1t1.c1)) = bmt1.c1)
2250                                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2251                                              Hash Cond: ((max(b2t1.c1)) = (max(b1t1.c1)))
2252                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2253                                                    Merge Cond: ((max(b2t1.c1)) = (max(b3t1.c1)))
2254                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2255                                                          Sort Key: (max(b2t1.c1))
2256                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2257                                                                ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2258                                                                      ->  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
2259                                                                            Hash Cond: (b2t3.c1 = b2t1.c1)
2260                                                                            ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
2261                                                                                  Merge Cond: (b2t3.c1 = b2t4.c1)
2262                                                                                  ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2263                                                                                  ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2264                                                                            ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
2265                                                                                  ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2266                                                                      ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2267                                                                            Index Cond: (c1 = b2t1.c1)
2268                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2269                                                          Sort Key: (max(b3t1.c1))
2270                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2271                                                                ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2272                                                                      ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
2273                                                                            Hash Cond: (b3t1.c1 = b3t2.c1)
2274                                                                            ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
2275                                                                                  Merge Cond: (b3t1.c1 = b3t4.c1)
2276                                                                                  ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2277                                                                                  ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
2278                                                                            ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
2279                                                                                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
2280                                                                      ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
2281                                                                            Index Cond: (c1 = b3t1.c1)
2282                                              ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2283                                                    ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2284                                                          ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2285                                                                Join Filter: (b1t2.c1 = b1t1.c1)
2286                                                                ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
2287                                                                      Hash Cond: (b1t4.c1 = b1t2.c1)
2288                                                                      ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2289                                                                      ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
2290                                                                            ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2291                                                                                  Merge Cond: (b1t3.c1 = b1t2.c1)
2292                                                                                  ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2293                                                                                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2294                                                                                        Sort Key: b1t2.c1
2295                                                                                        ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2296                                                                ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2297                                                                      Index Cond: (c1 = b1t3.c1)
2298                                        ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2299                                              Index Cond: (c1 = (max(b2t1.c1)))
2300                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2301                                  Sort Key: bmt2.c1
2302                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
2303          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
2304                Index Cond: (c1 = bmt1.c1)
2305
2306 \o results/ut-R.tmpout
2307 /*+
2308 Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2309 Leading(b1t2 b1t3 b1t4 b1t1)
2310 Leading(b2t3 b2t4 b2t1 b2t2)
2311 Leading(b3t4 b3t1 b3t2 b3t3)
2312 MergeJoin(c3 c2)HashJoin(c3 c2 c1)NestLoop(c3 c2 c1 bmt1)MergeJoin(c3 c2 c1 bmt1 bmt2)HashJoin(c3 c2 c1 bmt1 bmt2 bmt3)NestLoop(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2313 MergeJoin(b1t2 b1t3)HashJoin(b1t2 b1t3 b1t4)NestLoop(b1t2 b1t3 b1t4 b1t1)
2314 MergeJoin(b2t3 b2t4)HashJoin(b2t3 b2t4 b2t1)NestLoop(b2t3 b2t4 b2t1 b2t2)
2315 MergeJoin(b3t4 b3t1)HashJoin(b3t4 b3t1 b3t2)NestLoop(b3t1 b3t2 b3t3 b3t4)
2316 Rows(c3 c2 #1)Rows(c3 c2 c1 #1)Rows(c3 c2 c1 bmt1 #1)Rows(c3 c2 c1 bmt1 bmt2 #1)Rows(c3 c2 c1 bmt1 bmt2 bmt3 #1)Rows(c3 c2 c1 bmt1 bmt2 bmt3 bmt4 #1)
2317 Rows(b1t2 b1t3 #1)Rows(b1t2 b1t3 b1t4 #1)Rows(b1t2 b1t3 b1t4 b1t1 #1)
2318 Rows(b2t3 b2t4 #1)Rows(b2t3 b2t4 b2t1 #1)Rows(b2t3 b2t4 b2t1 b2t2 #1)
2319 Rows(b3t4 b3t1 #1)Rows(b3t4 b3t1 b3t2 #1)Rows(b3t1 b3t2 b3t3 b3t4 #1)
2320 */
2321 EXPLAIN
2322 WITH c1 (c1) AS (
2323 SELECT max(b1t1.c1) FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2324 )
2325 , c2 (c1) AS (
2326 SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
2327 )
2328 , c3 (c1) AS (
2329 SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
2330 )
2331 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4
2332 , c1, c2, c3
2333                                                                         WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1
2334 AND bmt1.c1 = c1.c1
2335 AND bmt1.c1 = c2.c1
2336 AND bmt1.c1 = c3.c1;
2337 LOG:  pg_hint_plan:
2338 used hint:
2339 MergeJoin(b1t2 b1t3)
2340 MergeJoin(b2t3 b2t4)
2341 MergeJoin(b3t1 b3t4)
2342 MergeJoin(c2 c3)
2343 HashJoin(b1t2 b1t3 b1t4)
2344 HashJoin(b2t1 b2t3 b2t4)
2345 HashJoin(b3t1 b3t2 b3t4)
2346 HashJoin(c1 c2 c3)
2347 NestLoop(b1t1 b1t2 b1t3 b1t4)
2348 NestLoop(b2t1 b2t2 b2t3 b2t4)
2349 NestLoop(b3t1 b3t2 b3t3 b3t4)
2350 NestLoop(bmt1 c1 c2 c3)
2351 MergeJoin(bmt1 bmt2 c1 c2 c3)
2352 HashJoin(bmt1 bmt2 bmt3 c1 c2 c3)
2353 NestLoop(bmt1 bmt2 bmt3 bmt4 c1 c2 c3)
2354 Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
2355 Leading(b1t2 b1t3 b1t4 b1t1)
2356 Leading(b2t3 b2t4 b2t1 b2t2)
2357 Leading(b3t4 b3t1 b3t2 b3t3)
2358 Rows(b1t2 b1t3 #1)
2359 Rows(b2t3 b2t4 #1)
2360 Rows(b3t1 b3t4 #1)
2361 Rows(c2 c3 #1)
2362 Rows(b1t2 b1t3 b1t4 #1)
2363 Rows(b2t1 b2t3 b2t4 #1)
2364 Rows(b3t1 b3t2 b3t4 #1)
2365 Rows(c1 c2 c3 #1)
2366 Rows(b1t1 b1t2 b1t3 b1t4 #1)
2367 Rows(b2t1 b2t2 b2t3 b2t4 #1)
2368 Rows(b3t1 b3t2 b3t3 b3t4 #1)
2369 Rows(bmt1 c1 c2 c3 #1)
2370 Rows(bmt1 bmt2 c1 c2 c3 #1)
2371 Rows(bmt1 bmt2 bmt3 c1 c2 c3 #1)
2372 Rows(bmt1 bmt2 bmt3 bmt4 c1 c2 c3 #1)
2373 not used hint:
2374 duplication hint:
2375 error hint:
2376
2377 \o
2378 \! sql/maskout.sh results/ut-R.tmpout
2379                                                                                QUERY PLAN                                                                               
2380 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2381  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2382    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2383          ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2384                Hash Cond: (bmt3.c1 = bmt1.c1)
2385                ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
2386                ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2387                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2388                            Merge Cond: (bmt1.c1 = bmt2.c1)
2389                            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2390                                  Sort Key: bmt1.c1
2391                                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2392                                        Join Filter: ((max(b1t1.c1)) = bmt1.c1)
2393                                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2394                                              Hash Cond: ((max(b2t1.c1)) = (max(b1t1.c1)))
2395                                              ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2396                                                    Merge Cond: ((max(b2t1.c1)) = (max(b3t1.c1)))
2397                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2398                                                          Sort Key: (max(b2t1.c1))
2399                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2400                                                                ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2401                                                                      ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2402                                                                            Hash Cond: (b2t1.c1 = b2t3.c1)
2403                                                                            ->  Seq Scan on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2404                                                                            ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2405                                                                                  ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2406                                                                                        Merge Cond: (b2t3.c1 = b2t4.c1)
2407                                                                                        ->  Index Only Scan using t3_i1 on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2408                                                                                        ->  Index Only Scan using t4_i1 on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2409                                                                      ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2410                                                                            Index Cond: (c1 = b2t1.c1)
2411                                                    ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2412                                                          Sort Key: (max(b3t1.c1))
2413                                                          ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2414                                                                ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2415                                                                      ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2416                                                                            Hash Cond: (b3t1.c1 = b3t2.c1)
2417                                                                            ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2418                                                                                  Merge Cond: (b3t1.c1 = b3t4.c1)
2419                                                                                  ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2420                                                                                  ->  Index Only Scan using t4_i1 on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
2421                                                                            ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
2422                                                                                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
2423                                                                      ->  Index Only Scan using t3_i1 on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
2424                                                                            Index Cond: (c1 = b3t1.c1)
2425                                              ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2426                                                    ->  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
2427                                                          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2428                                                                Join Filter: (b1t2.c1 = b1t1.c1)
2429                                                                ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2430                                                                      Hash Cond: (b1t4.c1 = b1t2.c1)
2431                                                                      ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2432                                                                      ->  Hash  (cost=xxx..xxx rows=1 width=xxx)
2433                                                                            ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2434                                                                                  Merge Cond: (b1t3.c1 = b1t2.c1)
2435                                                                                  ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2436                                                                                  ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2437                                                                                        Sort Key: b1t2.c1
2438                                                                                        ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2439                                                                ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2440                                                                      Index Cond: (c1 = b1t3.c1)
2441                                        ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2442                                              Index Cond: (c1 = (max(b2t1.c1)))
2443                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2444                                  Sort Key: bmt2.c1
2445                                  ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
2446          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
2447                Index Cond: (c1 = bmt1.c1)
2448
2449 ----
2450 ---- No. R-2-2 the number of the tables per quiry block
2451 ----
2452 -- No. R-2-2-1
2453 \o results/ut-R.tmpout
2454 /*+
2455 Leading(c1 bmt1)
2456 */
2457 EXPLAIN
2458 WITH c1 (c1) AS (
2459 SELECT b1t1.c1 FROM s1.t1 b1t1 WHERE b1t1.c1 = 1
2460 )
2461 SELECT bmt1.c1, (
2462 SELECT b2t1.c1 FROM s1.t1 b2t1 WHERE b2t1.c1 = 1
2463 )
2464                     FROM s1.t1 bmt1, c1 WHERE bmt1.c1 = 1
2465 AND bmt1.c1 = c1.c1
2466 AND bmt1.c1 <> (
2467 SELECT b3t1.c1 FROM s1.t1 b3t1 WHERE b3t1.c1 = 1
2468 );
2469 LOG:  pg_hint_plan:
2470 used hint:
2471 not used hint:
2472 Leading(c1 bmt1)
2473 duplication hint:
2474 error hint:
2475
2476 \o
2477 \! sql/maskout.sh results/ut-R.tmpout
2478                                     QUERY PLAN                                    
2479 ----------------------------------------------------------------------------------
2480  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2481    InitPlan 1 (returns $0)
2482      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
2483            Index Cond: (c1 = 1)
2484    InitPlan 2 (returns $1)
2485      ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
2486            Index Cond: (c1 = 1)
2487    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2488          Index Cond: (c1 = 1)
2489          Filter: (c1 <> $1)
2490    ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2491          Index Cond: (c1 = 1)
2492
2493 \o results/ut-R.tmpout
2494 /*+
2495 Leading(c1 bmt1)
2496 Rows(bmt1 c1 #1)
2497 Rows(b1t1 c1 #1)
2498 Rows(b2t1 c1 #1)
2499 Rows(b3t1 c1 #1)
2500 */
2501 EXPLAIN
2502 WITH c1 (c1) AS (
2503 SELECT b1t1.c1 FROM s1.t1 b1t1 WHERE b1t1.c1 = 1
2504 )
2505 SELECT bmt1.c1, (
2506 SELECT b2t1.c1 FROM s1.t1 b2t1 WHERE b2t1.c1 = 1
2507 )
2508                     FROM s1.t1 bmt1, c1 WHERE bmt1.c1 = 1
2509 AND bmt1.c1 = c1.c1
2510 AND bmt1.c1 <> (
2511 SELECT b3t1.c1 FROM s1.t1 b3t1 WHERE b3t1.c1 = 1
2512 );
2513 LOG:  pg_hint_plan:
2514 used hint:
2515 not used hint:
2516 Leading(c1 bmt1)
2517 Rows(b1t1 c1 #1)
2518 Rows(b2t1 c1 #1)
2519 Rows(b3t1 c1 #1)
2520 Rows(bmt1 c1 #1)
2521 duplication hint:
2522 error hint:
2523
2524 \o
2525 \! sql/maskout.sh results/ut-R.tmpout
2526                                     QUERY PLAN                                    
2527 ----------------------------------------------------------------------------------
2528  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2529    InitPlan 1 (returns $0)
2530      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
2531            Index Cond: (c1 = 1)
2532    InitPlan 2 (returns $1)
2533      ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
2534            Index Cond: (c1 = 1)
2535    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2536          Index Cond: (c1 = 1)
2537          Filter: (c1 <> $1)
2538    ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
2539          Index Cond: (c1 = 1)
2540
2541 -- No. R-2-2-2
2542 \o results/ut-R.tmpout
2543 /*+
2544 Leading(c1 bmt2 bmt1)
2545 Leading(b1t2 b1t1)
2546 Leading(b2t2 b2t1)
2547 Leading(b3t2 b3t1)
2548 MergeJoin(c1 bmt2)
2549 HashJoin(c1 bmt1 bmt2)
2550 MergeJoin(b1t1 b1t2)
2551 MergeJoin(b2t1 b2t2)
2552 MergeJoin(b3t1 b3t2)
2553 */
2554 EXPLAIN
2555 WITH c1 (c1) AS (
2556 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2 WHERE b1t1.c1 = b1t2.c1
2557 )
2558 SELECT bmt1.c1, (
2559 SELECT b2t1.c1 FROM s1.t1 b2t1, s1.t2 b2t2 WHERE b2t1.c1 = b2t2.c1
2560 )
2561                     FROM s1.t1 bmt1, s1.t2 bmt2, c1 WHERE bmt1.c1 = bmt2.c1
2562 AND bmt1.c1 = c1.c1
2563 AND bmt1.c1 <> (
2564 SELECT b3t1.c1 FROM s1.t1 b3t1, s1.t2 b3t2 WHERE b3t1.c1 = b3t2.c1
2565 );
2566 LOG:  pg_hint_plan:
2567 used hint:
2568 MergeJoin(b1t1 b1t2)
2569 MergeJoin(b2t1 b2t2)
2570 MergeJoin(b3t1 b3t2)
2571 Leading(b1t2 b1t1)
2572 Leading(b2t2 b2t1)
2573 Leading(b3t2 b3t1)
2574 not used hint:
2575 MergeJoin(bmt2 c1)
2576 HashJoin(bmt1 bmt2 c1)
2577 Leading(c1 bmt2 bmt1)
2578 duplication hint:
2579 error hint:
2580
2581 \o
2582 \! sql/maskout.sh results/ut-R.tmpout
2583                                            QUERY PLAN                                           
2584 ------------------------------------------------------------------------------------------------
2585  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2586    Join Filter: (bmt1.c1 = bmt2.c1)
2587    InitPlan 1 (returns $0)
2588      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2589            Merge Cond: (b2t1.c1 = b2t2.c1)
2590            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2591            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2592                  Sort Key: b2t2.c1
2593                  ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=100 width=xxx)
2594    InitPlan 2 (returns $1)
2595      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2596            Merge Cond: (b3t1.c1 = b3t2.c1)
2597            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2598            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2599                  Sort Key: b3t2.c1
2600                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
2601    ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
2602          ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2603                Merge Cond: (b1t1.c1 = b1t2.c1)
2604                ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
2605                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2606                      Sort Key: b1t2.c1
2607                      ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2608          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2609                Index Cond: (c1 = b1t1.c1)
2610                Filter: (c1 <> $1)
2611    ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2612          Index Cond: (c1 = b1t1.c1)
2613
2614 \o results/ut-R.tmpout
2615 /*+
2616 Leading(c1 bmt2 bmt1)
2617 Leading(b1t2 b1t1)
2618 Leading(b2t2 b2t1)
2619 Leading(b3t2 b3t1)
2620 MergeJoin(c1 bmt2)
2621 HashJoin(c1 bmt1 bmt2)
2622 MergeJoin(b1t1 b1t2)
2623 MergeJoin(b2t1 b2t2)
2624 MergeJoin(b3t1 b3t2)
2625 Rows(c1 bmt2 #1)
2626 Rows(c1 bmt1 bmt2 #1)
2627 Rows(b1t1 b1t2 #1)
2628 Rows(b2t1 b2t2 #1)
2629 Rows(b3t1 b3t2 #1)
2630 */
2631 EXPLAIN
2632 WITH c1 (c1) AS (
2633 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2 WHERE b1t1.c1 = b1t2.c1
2634 )
2635 SELECT bmt1.c1, (
2636 SELECT b2t1.c1 FROM s1.t1 b2t1, s1.t2 b2t2 WHERE b2t1.c1 = b2t2.c1
2637 )
2638                     FROM s1.t1 bmt1, s1.t2 bmt2, c1 WHERE bmt1.c1 = bmt2.c1
2639 AND bmt1.c1 = c1.c1
2640 AND bmt1.c1 <> (
2641 SELECT b3t1.c1 FROM s1.t1 b3t1, s1.t2 b3t2 WHERE b3t1.c1 = b3t2.c1
2642 )
2643 ;
2644 LOG:  pg_hint_plan:
2645 used hint:
2646 MergeJoin(b1t1 b1t2)
2647 MergeJoin(b2t1 b2t2)
2648 MergeJoin(b3t1 b3t2)
2649 Leading(b1t2 b1t1)
2650 Leading(b2t2 b2t1)
2651 Leading(b3t2 b3t1)
2652 Rows(b1t1 b1t2 #1)
2653 Rows(b2t1 b2t2 #1)
2654 Rows(b3t1 b3t2 #1)
2655 not used hint:
2656 MergeJoin(bmt2 c1)
2657 HashJoin(bmt1 bmt2 c1)
2658 Leading(c1 bmt2 bmt1)
2659 Rows(bmt2 c1 #1)
2660 Rows(bmt1 bmt2 c1 #1)
2661 duplication hint:
2662 error hint:
2663
2664 \o
2665 \! sql/maskout.sh results/ut-R.tmpout
2666                                            QUERY PLAN                                           
2667 ------------------------------------------------------------------------------------------------
2668  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2669    Join Filter: (bmt1.c1 = bmt2.c1)
2670    InitPlan 1 (returns $0)
2671      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2672            Merge Cond: (b2t1.c1 = b2t2.c1)
2673            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2674            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2675                  Sort Key: b2t2.c1
2676                  ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=100 width=xxx)
2677    InitPlan 2 (returns $1)
2678      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2679            Merge Cond: (b3t1.c1 = b3t2.c1)
2680            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2681            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2682                  Sort Key: b3t2.c1
2683                  ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=100 width=xxx)
2684    ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
2685          ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2686                Merge Cond: (b1t1.c1 = b1t2.c1)
2687                ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
2688                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2689                      Sort Key: b1t2.c1
2690                      ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
2691          ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2692                Index Cond: (c1 = b1t1.c1)
2693                Filter: (c1 <> $1)
2694    ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2695          Index Cond: (c1 = b1t1.c1)
2696
2697 -- No. R-2-2-3
2698 \o results/ut-R.tmpout
2699 /*+
2700 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2701 Leading(b1t4 b1t3 b1t2 b1t1) 
2702 Leading(b2t4 b2t3 b2t2 b2t1)
2703 Leading(b3t4 b3t3 b3t2 b3t1)
2704 MergeJoin(c1 bmt4)
2705 HashJoin(c1 bmt4 bmt3)
2706 NestLoop(c1 bmt4 bmt3 bmt2)
2707 MergeJoin(c1 bmt4 bmt3 bmt2 bmt1)
2708 HashJoin(b1t4 b1t3)
2709 NestLoop(b1t4 b1t3 b1t2)
2710 MergeJoin(b1t4 b1t3 b1t2 b1t1)
2711 HashJoin(b2t4 b2t3)
2712 NestLoop(b2t4 b2t3 b2t2)
2713 MergeJoin(b2t4 b2t3 b2t2 b2t1)
2714 HashJoin(b3t4 b3t3)
2715 NestLoop(b3t4 b3t3 b3t2)
2716 MergeJoin(b3t4 b3t3 b3t2 b3t1)
2717 */
2718 EXPLAIN
2719 WITH c1 (c1) AS (
2720 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2721 )
2722 SELECT bmt1.c1, (
2723 SELECT b2t1.c1 FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
2724 )
2725                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4, c1 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1 AND bmt1.c1 = c1.c1
2726 AND bmt1.c1 <> (
2727 SELECT b3t1.c1 FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
2728 );
2729 LOG:  pg_hint_plan:
2730 used hint:
2731 HashJoin(b1t3 b1t4)
2732 HashJoin(b2t3 b2t4)
2733 HashJoin(b3t3 b3t4)
2734 NestLoop(b1t2 b1t3 b1t4)
2735 NestLoop(b2t2 b2t3 b2t4)
2736 NestLoop(b3t2 b3t3 b3t4)
2737 MergeJoin(b1t1 b1t2 b1t3 b1t4)
2738 MergeJoin(b2t1 b2t2 b2t3 b2t4)
2739 MergeJoin(b3t1 b3t2 b3t3 b3t4)
2740 Leading(b1t4 b1t3 b1t2 b1t1)
2741 Leading(b2t4 b2t3 b2t2 b2t1)
2742 Leading(b3t4 b3t3 b3t2 b3t1)
2743 not used hint:
2744 MergeJoin(bmt4 c1)
2745 HashJoin(bmt3 bmt4 c1)
2746 NestLoop(bmt2 bmt3 bmt4 c1)
2747 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
2748 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2749 duplication hint:
2750 error hint:
2751
2752 \o
2753 \! sql/maskout.sh results/ut-R.tmpout
2754                                                      QUERY PLAN                                                     
2755 --------------------------------------------------------------------------------------------------------------------
2756  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2757    Join Filter: (bmt1.c1 = bmt4.c1)
2758    InitPlan 1 (returns $1)
2759      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2760            Merge Cond: (b2t1.c1 = b2t2.c1)
2761            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2762            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2763                  Sort Key: b2t2.c1
2764                  ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2765                        ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
2766                              Hash Cond: (b2t3.c1 = b2t4.c1)
2767                              ->  Seq Scan on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2768                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2769                                    ->  Seq Scan on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2770                        ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2771                              Index Cond: (c1 = b2t3.c1)
2772    InitPlan 2 (returns $3)
2773      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2774            Merge Cond: (b3t1.c1 = b3t2.c1)
2775            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2776            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2777                  Sort Key: b3t2.c1
2778                  ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2779                        ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
2780                              Hash Cond: (b3t3.c1 = b3t4.c1)
2781                              ->  Seq Scan on t3 b3t3  (cost=xxx..xxx rows=1130 width=xxx)
2782                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2783                                    ->  Seq Scan on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
2784                        ->  Index Only Scan using t2_i1 on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
2785                              Index Cond: (c1 = b3t3.c1)
2786    ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2787          Join Filter: (bmt1.c1 = bmt3.c1)
2788          ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2789                Join Filter: (bmt1.c1 = bmt2.c1)
2790                ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
2791                      Join Filter: (b1t1.c1 = bmt1.c1)
2792                      ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
2793                            Merge Cond: (b1t1.c1 = b1t2.c1)
2794                            ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
2795                            ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
2796                                  Sort Key: b1t2.c1
2797                                  ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
2798                                        ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
2799                                              Hash Cond: (b1t3.c1 = b1t4.c1)
2800                                              ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2801                                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2802                                                    ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2803                                        ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
2804                                              Index Cond: (c1 = b1t3.c1)
2805                      ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2806                            Index Cond: (c1 = b1t3.c1)
2807                            Filter: (c1 <> $3)
2808                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2809                      Index Cond: (c1 = b1t3.c1)
2810          ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
2811                Index Cond: (c1 = b1t3.c1)
2812    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
2813          Index Cond: (c1 = bmt3.c1)
2814
2815 \o results/ut-R.tmpout
2816 /*+
2817 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2818 Leading(b1t4 b1t3 b1t2 b1t1) 
2819 Leading(b2t4 b2t3 b2t2 b2t1)
2820 Leading(b3t4 b3t3 b3t2 b3t1)
2821 MergeJoin(c1 bmt4)
2822 HashJoin(c1 bmt4 bmt3)
2823 NestLoop(c1 bmt4 bmt3 bmt2)
2824 MergeJoin(c1 bmt4 bmt3 bmt2 bmt1)
2825 HashJoin(b1t4 b1t3)
2826 NestLoop(b1t4 b1t3 b1t2)
2827 MergeJoin(b1t4 b1t3 b1t2 b1t1)
2828 HashJoin(b2t4 b2t3)
2829 NestLoop(b2t4 b2t3 b2t2)
2830 MergeJoin(b2t4 b2t3 b2t2 b2t1)
2831 HashJoin(b3t4 b3t3)
2832 NestLoop(b3t4 b3t3 b3t2)
2833 MergeJoin(b3t4 b3t3 b3t2 b3t1)
2834 Rows(c1 bmt4 #1)
2835 Rows(c1 bmt4 bmt3 #1)
2836 Rows(c1 bmt4 bmt3 bmt2 #1)
2837 Rows(c1 bmt4 bmt3 bmt2 bmt1 #1)
2838 Rows(b1t4 b1t3 #1)
2839 Rows(b1t4 b1t3 b1t2 #1)
2840 Rows(b1t4 b1t3 b1t2 b1t1 #1)
2841 Rows(b2t4 b2t3 #1)
2842 Rows(b2t4 b2t3 b2t2 #1)
2843 Rows(b2t4 b2t3 b2t2 b2t1 #1)
2844 Rows(b3t4 b3t3 #1)
2845 Rows(b3t4 b3t3 b3t2 #1)
2846 Rows(b3t4 b3t3 b3t2 b3t1 #1)
2847 */
2848 EXPLAIN
2849 WITH c1 (c1) AS (
2850 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2851 )
2852 SELECT bmt1.c1, (
2853 SELECT b2t1.c1 FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2t1.c1 = b2t2.c1 AND b2t1.c1 = b2t3.c1 AND b2t1.c1 = b2t4.c1
2854 )
2855                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4, c1 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1 AND bmt1.c1 = c1.c1
2856 AND bmt1.c1 <> (
2857 SELECT b3t1.c1 FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3t1.c1 = b3t2.c1 AND b3t1.c1 = b3t3.c1 AND b3t1.c1 = b3t4.c1
2858 );
2859 LOG:  pg_hint_plan:
2860 used hint:
2861 HashJoin(b1t3 b1t4)
2862 HashJoin(b2t3 b2t4)
2863 HashJoin(b3t3 b3t4)
2864 NestLoop(b1t2 b1t3 b1t4)
2865 NestLoop(b2t2 b2t3 b2t4)
2866 NestLoop(b3t2 b3t3 b3t4)
2867 MergeJoin(b1t1 b1t2 b1t3 b1t4)
2868 MergeJoin(b2t1 b2t2 b2t3 b2t4)
2869 MergeJoin(b3t1 b3t2 b3t3 b3t4)
2870 Leading(b1t4 b1t3 b1t2 b1t1)
2871 Leading(b2t4 b2t3 b2t2 b2t1)
2872 Leading(b3t4 b3t3 b3t2 b3t1)
2873 Rows(b1t3 b1t4 #1)
2874 Rows(b2t3 b2t4 #1)
2875 Rows(b3t3 b3t4 #1)
2876 Rows(b1t2 b1t3 b1t4 #1)
2877 Rows(b2t2 b2t3 b2t4 #1)
2878 Rows(b3t2 b3t3 b3t4 #1)
2879 Rows(b1t1 b1t2 b1t3 b1t4 #1)
2880 Rows(b2t1 b2t2 b2t3 b2t4 #1)
2881 Rows(b3t1 b3t2 b3t3 b3t4 #1)
2882 not used hint:
2883 MergeJoin(bmt4 c1)
2884 HashJoin(bmt3 bmt4 c1)
2885 NestLoop(bmt2 bmt3 bmt4 c1)
2886 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
2887 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2888 Rows(bmt4 c1 #1)
2889 Rows(bmt3 bmt4 c1 #1)
2890 Rows(bmt2 bmt3 bmt4 c1 #1)
2891 Rows(bmt1 bmt2 bmt3 bmt4 c1 #1)
2892 duplication hint:
2893 error hint:
2894
2895 \o
2896 \! sql/maskout.sh results/ut-R.tmpout
2897                                                      QUERY PLAN                                                     
2898 --------------------------------------------------------------------------------------------------------------------
2899  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2900    Join Filter: (bmt1.c1 = bmt4.c1)
2901    InitPlan 1 (returns $1)
2902      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2903            Merge Cond: (b2t1.c1 = b2t2.c1)
2904            ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1000 width=xxx)
2905            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2906                  Sort Key: b2t2.c1
2907                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2908                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2909                              Hash Cond: (b2t3.c1 = b2t4.c1)
2910                              ->  Seq Scan on t3 b2t3  (cost=xxx..xxx rows=1130 width=xxx)
2911                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2912                                    ->  Seq Scan on t4 b2t4  (cost=xxx..xxx rows=1130 width=xxx)
2913                        ->  Index Only Scan using t2_i1 on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
2914                              Index Cond: (c1 = b2t3.c1)
2915    InitPlan 2 (returns $3)
2916      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2917            Merge Cond: (b3t1.c1 = b3t2.c1)
2918            ->  Index Only Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
2919            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2920                  Sort Key: b3t2.c1
2921                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2922                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2923                              Hash Cond: (b3t3.c1 = b3t4.c1)
2924                              ->  Seq Scan on t3 b3t3  (cost=xxx..xxx rows=1130 width=xxx)
2925                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2926                                    ->  Seq Scan on t4 b3t4  (cost=xxx..xxx rows=1130 width=xxx)
2927                        ->  Index Only Scan using t2_i1 on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
2928                              Index Cond: (c1 = b3t3.c1)
2929    ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2930          Join Filter: (bmt1.c1 = bmt3.c1)
2931          ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
2932                Join Filter: (bmt1.c1 = bmt2.c1)
2933                ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
2934                      Join Filter: (b1t1.c1 = bmt1.c1)
2935                      ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
2936                            Merge Cond: (b1t1.c1 = b1t2.c1)
2937                            ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1000 width=xxx)
2938                            ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
2939                                  Sort Key: b1t2.c1
2940                                  ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
2941                                        ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
2942                                              Hash Cond: (b1t3.c1 = b1t4.c1)
2943                                              ->  Seq Scan on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
2944                                              ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
2945                                                    ->  Seq Scan on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
2946                                        ->  Index Only Scan using t2_i1 on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
2947                                              Index Cond: (c1 = b1t3.c1)
2948                      ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
2949                            Index Cond: (c1 = b1t3.c1)
2950                            Filter: (c1 <> $3)
2951                ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=1 width=xxx)
2952                      Index Cond: (c1 = b1t3.c1)
2953          ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
2954                Index Cond: (c1 = b1t3.c1)
2955    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
2956          Index Cond: (c1 = bmt3.c1)
2957
2958 -- No. R-2-2-4
2959 \o results/ut-R.tmpout
2960 /*+
2961 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2962 Leading(b1t4 b1t3 b1t2 b1t1)
2963 MergeJoin(c1 bmt4)
2964 HashJoin(c1 bmt4 bmt3)
2965 NestLoop(c1 bmt4 bmt3 bmt2)
2966 MergeJoin(c1 bmt4 bmt3 bmt2 bmt1)
2967 MergeJoin(b1t4 b1t3)
2968 HashJoin(b1t4 b1t3 b1t2)
2969 NestLoop(b1t4 b1t3 b1t2 b1t1)
2970 */
2971 EXPLAIN
2972 WITH c1 (c1) AS (
2973 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
2974 )
2975 SELECT bmt1.c1, (
2976 SELECT b2t1.c1 FROM s1.t1 b2t1 WHERE b2t1.c1 = 1
2977 )
2978                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4, c1 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1 AND bmt1.c1 = c1.c1
2979 AND bmt1.c1 <> (
2980 SELECT b3t1.c1 FROM s1.t1 b3t1
2981 );
2982 LOG:  pg_hint_plan:
2983 used hint:
2984 MergeJoin(b1t3 b1t4)
2985 HashJoin(b1t2 b1t3 b1t4)
2986 NestLoop(b1t1 b1t2 b1t3 b1t4)
2987 Leading(b1t4 b1t3 b1t2 b1t1)
2988 not used hint:
2989 MergeJoin(bmt4 c1)
2990 HashJoin(bmt3 bmt4 c1)
2991 NestLoop(bmt2 bmt3 bmt4 c1)
2992 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
2993 Leading(c1 bmt4 bmt3 bmt2 bmt1)
2994 duplication hint:
2995 error hint:
2996
2997 \o
2998 \! sql/maskout.sh results/ut-R.tmpout
2999                                                           QUERY PLAN                                                          
3000 ------------------------------------------------------------------------------------------------------------------------------
3001  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3002    Join Filter: (bmt1.c1 = bmt4.c1)
3003    InitPlan 1 (returns $0)
3004      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
3005            Index Cond: (c1 = 1)
3006    InitPlan 2 (returns $1)
3007      ->  Seq Scan on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
3008    ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3009          Join Filter: (bmt1.c1 = bmt3.c1)
3010          ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3011                Join Filter: (bmt2.c1 = bmt1.c1)
3012                ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
3013                      Join Filter: (b1t1.c1 = bmt2.c1)
3014                      ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
3015                      ->  Materialize  (cost=xxx..xxx rows=100 width=xxx)
3016                            ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
3017                                  Join Filter: (b1t2.c1 = b1t1.c1)
3018                                  ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
3019                                        Hash Cond: (b1t3.c1 = b1t2.c1)
3020                                        ->  Merge Join  (cost=xxx..xxx rows=1130 width=xxx)
3021                                              Merge Cond: (b1t3.c1 = b1t4.c1)
3022                                              ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
3023                                              ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
3024                                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
3025                                              ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
3026                                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3027                                        Index Cond: (c1 = b1t3.c1)
3028                ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
3029                      Index Cond: (c1 = b1t3.c1)
3030                      Filter: (c1 <> $1)
3031          ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
3032                Index Cond: (c1 = b1t3.c1)
3033    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
3034          Index Cond: (c1 = bmt3.c1)
3035
3036 \o results/ut-R.tmpout
3037 /*+
3038 Leading(c1 bmt4 bmt3 bmt2 bmt1)
3039 Leading(b1t4 b1t3 b1t2 b1t1)
3040 MergeJoin(c1 bmt4)
3041 HashJoin(c1 bmt4 bmt3)
3042 NestLoop(c1 bmt4 bmt3 bmt2)
3043 MergeJoin(c1 bmt4 bmt3 bmt2 bmt1)
3044 MergeJoin(b1t4 b1t3)
3045 HashJoin(b1t4 b1t3 b1t2)
3046 NestLoop(b1t4 b1t3 b1t2 b1t1)
3047 Rows(c1 bmt4 #1)
3048 Rows(c1 bmt4 bmt3 #1)
3049 Rows(c1 bmt4 bmt3 bmt2 #1)
3050 Rows(c1 bmt4 bmt3 bmt2 bmt1 #1)
3051 Rows(b1t4 b1t3 #1)
3052 Rows(b1t4 b1t3 b1t2 #1)
3053 Rows(b1t4 b1t3 b1t2 b1t1 #1)
3054 */
3055 EXPLAIN
3056 WITH c1 (c1) AS (
3057 SELECT b1t1.c1 FROM s1.t1 b1t1, s1.t2 b1t2, s1.t3 b1t3, s1.t4 b1t4 WHERE b1t1.c1 = b1t2.c1 AND b1t1.c1 = b1t3.c1 AND b1t1.c1 = b1t4.c1
3058 )
3059 SELECT bmt1.c1, (
3060 SELECT b2t1.c1 FROM s1.t1 b2t1 WHERE b2t1.c1 = 1
3061 )
3062                     FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4, c1 WHERE bmt1.c1 = bmt2.c1 AND bmt1.c1 = bmt3.c1 AND bmt1.c1 = bmt4.c1 AND bmt1.c1 = c1.c1
3063 AND bmt1.c1 <> (
3064 SELECT b3t1.c1 FROM s1.t1 b3t1
3065 );
3066 LOG:  pg_hint_plan:
3067 used hint:
3068 MergeJoin(b1t3 b1t4)
3069 HashJoin(b1t2 b1t3 b1t4)
3070 NestLoop(b1t1 b1t2 b1t3 b1t4)
3071 Leading(b1t4 b1t3 b1t2 b1t1)
3072 Rows(b1t3 b1t4 #1)
3073 Rows(b1t2 b1t3 b1t4 #1)
3074 Rows(b1t1 b1t2 b1t3 b1t4 #1)
3075 not used hint:
3076 MergeJoin(bmt4 c1)
3077 HashJoin(bmt3 bmt4 c1)
3078 NestLoop(bmt2 bmt3 bmt4 c1)
3079 MergeJoin(bmt1 bmt2 bmt3 bmt4 c1)
3080 Leading(c1 bmt4 bmt3 bmt2 bmt1)
3081 Rows(bmt4 c1 #1)
3082 Rows(bmt3 bmt4 c1 #1)
3083 Rows(bmt2 bmt3 bmt4 c1 #1)
3084 Rows(bmt1 bmt2 bmt3 bmt4 c1 #1)
3085 duplication hint:
3086 error hint:
3087
3088 \o
3089 \! sql/maskout.sh results/ut-R.tmpout
3090                                                           QUERY PLAN                                                          
3091 ------------------------------------------------------------------------------------------------------------------------------
3092  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3093    Join Filter: (bmt1.c1 = bmt4.c1)
3094    InitPlan 1 (returns $0)
3095      ->  Index Only Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
3096            Index Cond: (c1 = 1)
3097    InitPlan 2 (returns $1)
3098      ->  Seq Scan on t1 b3t1  (cost=xxx..xxx rows=1000 width=xxx)
3099    ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3100          Join Filter: (bmt1.c1 = bmt3.c1)
3101          ->  Nested Loop  (cost=xxx..xxx rows=10 width=xxx)
3102                Join Filter: (bmt2.c1 = bmt1.c1)
3103                ->  Nested Loop  (cost={inf}..{inf} rows=100 width=xxx)
3104                      Join Filter: (b1t1.c1 = bmt2.c1)
3105                      ->  Index Only Scan using t2_i1 on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
3106                      ->  Materialize  (cost=xxx..xxx rows=1 width=xxx)
3107                            ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3108                                  Join Filter: (b1t2.c1 = b1t1.c1)
3109                                  ->  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
3110                                        Hash Cond: (b1t3.c1 = b1t2.c1)
3111                                        ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3112                                              Merge Cond: (b1t3.c1 = b1t4.c1)
3113                                              ->  Index Only Scan using t3_i1 on t3 b1t3  (cost=xxx..xxx rows=1130 width=xxx)
3114                                              ->  Index Only Scan using t4_i1 on t4 b1t4  (cost=xxx..xxx rows=1130 width=xxx)
3115                                        ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
3116                                              ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=100 width=xxx)
3117                                  ->  Index Only Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3118                                        Index Cond: (c1 = b1t3.c1)
3119                ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1 width=xxx)
3120                      Index Cond: (c1 = b1t3.c1)
3121                      Filter: (c1 <> $1)
3122          ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1 width=xxx)
3123                Index Cond: (c1 = b1t3.c1)
3124    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
3125          Index Cond: (c1 = bmt3.c1)
3126
3127 ----
3128 ---- No. R-2-3 RULE or VIEW
3129 ----
3130 -- No. R-2-3-1
3131 \o results/ut-R.tmpout
3132 /*+
3133 Leading(r1 t1 t2 t3 t4)
3134 */
3135 EXPLAIN UPDATE s1.r1 SET c1 = c1 WHERE c1 = 1;
3136 LOG:  pg_hint_plan:
3137 used hint:
3138 Leading(r1 t1 t2 t3 t4)
3139 not used hint:
3140 duplication hint:
3141 error hint:
3142
3143 \o
3144 \! sql/maskout.sh results/ut-R.tmpout
3145                                           QUERY PLAN                                           
3146 -----------------------------------------------------------------------------------------------
3147  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3148    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3149          Join Filter: (t1.c1 = t4.c1)
3150          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3151                Join Filter: (t1.c1 = t3.c1)
3152                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3153                      Merge Cond: (t1.c1 = t2.c1)
3154                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3155                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3156                                  Filter: (ctid = '(1,1)'::tid)
3157                            ->  Seq Scan on r1  (cost=xxx..xxx rows=6 width=xxx)
3158                                  Filter: (c1 = 1)
3159                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3160                            Sort Key: t2.c1
3161                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3162                                  Filter: (ctid = '(1,1)'::tid)
3163                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3164                      TID Cond: (ctid = '(1,1)'::tid)
3165          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3166                TID Cond: (ctid = '(1,1)'::tid)
3167
3168 \o results/ut-R.tmpout
3169 /*+
3170 Leading(r1 t1 t2 t3 t4)
3171 Rows(r1 t1 t2 t3 t4 #2)
3172 Rows(r1 t1 t2 t3 #2)
3173 Rows(r1 t1 t2 #2)
3174 Rows(r1 t1 #2)
3175 */
3176 EXPLAIN UPDATE s1.r1 SET c1 = c1 WHERE c1 = 1;
3177 LOG:  pg_hint_plan:
3178 used hint:
3179 Leading(r1 t1 t2 t3 t4)
3180 Rows(r1 t1 #2)
3181 Rows(r1 t1 t2 #2)
3182 Rows(r1 t1 t2 t3 #2)
3183 Rows(r1 t1 t2 t3 t4 #2)
3184 not used hint:
3185 duplication hint:
3186 error hint:
3187
3188 \o
3189 \! sql/maskout.sh results/ut-R.tmpout
3190                                    QUERY PLAN                                    
3191 ---------------------------------------------------------------------------------
3192  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3193    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3194          Join Filter: (t1.c1 = t4.c1)
3195          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3196                TID Cond: (ctid = '(1,1)'::tid)
3197          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3198                Join Filter: (t1.c1 = t3.c1)
3199                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3200                      TID Cond: (ctid = '(1,1)'::tid)
3201                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3202                      Join Filter: (t1.c1 = t2.c1)
3203                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3204                            Filter: (ctid = '(1,1)'::tid)
3205                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3206                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3207                                  TID Cond: (ctid = '(1,1)'::tid)
3208                            ->  Seq Scan on r1  (cost=xxx..xxx rows=6 width=xxx)
3209                                  Filter: (c1 = 1)
3210
3211 \o results/ut-R.tmpout
3212 /*+
3213 Leading(r1_ b1t1 b1t2 b1t3 b1t4)
3214 */
3215 EXPLAIN UPDATE s1.r1_ SET c1 = c1 WHERE c1 = 1;
3216 LOG:  pg_hint_plan:
3217 used hint:
3218 Leading(r1_ b1t1 b1t2 b1t3 b1t4)
3219 not used hint:
3220 duplication hint:
3221 error hint:
3222
3223 \o
3224 \! sql/maskout.sh results/ut-R.tmpout
3225                                              QUERY PLAN                                             
3226 ----------------------------------------------------------------------------------------------------
3227  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3228    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3229          Join Filter: (b1t1.c1 = b1t4.c1)
3230          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3231                Join Filter: (b1t1.c1 = b1t3.c1)
3232                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3233                      Merge Cond: (b1t1.c1 = b1t2.c1)
3234                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3235                            ->  Index Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3236                                  Filter: (ctid = '(1,1)'::tid)
3237                            ->  Seq Scan on r1_  (cost=xxx..xxx rows=6 width=xxx)
3238                                  Filter: (c1 = 1)
3239                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3240                            Sort Key: b1t2.c1
3241                            ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3242                                  Filter: (ctid = '(1,1)'::tid)
3243                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3244                      TID Cond: (ctid = '(1,1)'::tid)
3245          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3246                TID Cond: (ctid = '(1,1)'::tid)
3247
3248 \o results/ut-R.tmpout
3249 /*+
3250 Leading(r1_ b1t1 b1t2 b1t3 b1t4)
3251 Rows(r1_ b1t1 b1t2 b1t3 b1t4 #2)
3252 Rows(r1_ b1t1 b1t2 b1t3 #2)
3253 Rows(r1_ b1t1 b1t2 #2)
3254 Rows(r1_ b1t1 #2)
3255 */
3256 EXPLAIN UPDATE s1.r1_ SET c1 = c1 WHERE c1 = 1;
3257 LOG:  pg_hint_plan:
3258 used hint:
3259 Leading(r1_ b1t1 b1t2 b1t3 b1t4)
3260 Rows(b1t1 r1_ #2)
3261 Rows(b1t1 b1t2 r1_ #2)
3262 Rows(b1t1 b1t2 b1t3 r1_ #2)
3263 Rows(b1t1 b1t2 b1t3 b1t4 r1_ #2)
3264 not used hint:
3265 duplication hint:
3266 error hint:
3267
3268 \o
3269 \! sql/maskout.sh results/ut-R.tmpout
3270                                      QUERY PLAN                                      
3271 -------------------------------------------------------------------------------------
3272  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3273    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3274          Join Filter: (b1t1.c1 = b1t4.c1)
3275          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3276                TID Cond: (ctid = '(1,1)'::tid)
3277          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3278                Join Filter: (b1t1.c1 = b1t3.c1)
3279                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3280                      TID Cond: (ctid = '(1,1)'::tid)
3281                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3282                      Join Filter: (b1t1.c1 = b1t2.c1)
3283                      ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3284                            Filter: (ctid = '(1,1)'::tid)
3285                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3286                            ->  Tid Scan on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3287                                  TID Cond: (ctid = '(1,1)'::tid)
3288                            ->  Seq Scan on r1_  (cost=xxx..xxx rows=6 width=xxx)
3289                                  Filter: (c1 = 1)
3290
3291 -- No. R-2-3-2
3292 \o results/ut-R.tmpout
3293 /*+
3294 Leading(r2 t1 t2 t3 t4)
3295 */
3296 EXPLAIN UPDATE s1.r2 SET c1 = c1 WHERE c1 = 1;
3297 LOG:  pg_hint_plan:
3298 used hint:
3299 Leading(r2 t1 t2 t3 t4)
3300 not used hint:
3301 duplication hint:
3302 error hint:
3303
3304 LOG:  pg_hint_plan:
3305 used hint:
3306 Leading(r2 t1 t2 t3 t4)
3307 not used hint:
3308 duplication hint:
3309 error hint:
3310
3311 \o
3312 \! sql/maskout.sh results/ut-R.tmpout
3313                                           QUERY PLAN                                           
3314 -----------------------------------------------------------------------------------------------
3315  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3316    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3317          Join Filter: (t1.c1 = t4.c1)
3318          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3319                Join Filter: (t1.c1 = t3.c1)
3320                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3321                      Merge Cond: (t1.c1 = t2.c1)
3322                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3323                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3324                                  Filter: (ctid = '(1,1)'::tid)
3325                            ->  Seq Scan on r2  (cost=xxx..xxx rows=6 width=xxx)
3326                                  Filter: (c1 = 1)
3327                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3328                            Sort Key: t2.c1
3329                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3330                                  Filter: (ctid = '(1,1)'::tid)
3331                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3332                      TID Cond: (ctid = '(1,1)'::tid)
3333          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3334                TID Cond: (ctid = '(1,1)'::tid)
3335  
3336  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3337    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3338          Join Filter: (t1.c1 = t4.c1)
3339          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3340                Join Filter: (t1.c1 = t3.c1)
3341                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3342                      Merge Cond: (t1.c1 = t2.c1)
3343                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3344                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3345                                  Filter: (ctid = '(1,1)'::tid)
3346                            ->  Seq Scan on r2  (cost=xxx..xxx rows=6 width=xxx)
3347                                  Filter: (c1 = 1)
3348                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3349                            Sort Key: t2.c1
3350                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3351                                  Filter: (ctid = '(1,1)'::tid)
3352                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3353                      TID Cond: (ctid = '(1,1)'::tid)
3354          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3355                TID Cond: (ctid = '(1,1)'::tid)
3356
3357 \o results/ut-R.tmpout
3358 /*+
3359 Leading(r2 t1 t2 t3 t4)
3360 Rows(r2 t1 t2 t3 t4 #2)
3361 Rows(r2 t1 t2 t3 #2)
3362 Rows(r2 t1 t2 #2)
3363 Rows(r2 t1 #2)
3364 */
3365 EXPLAIN UPDATE s1.r2 SET c1 = c1 WHERE c1 = 1;
3366 LOG:  pg_hint_plan:
3367 used hint:
3368 Leading(r2 t1 t2 t3 t4)
3369 Rows(r2 t1 #2)
3370 Rows(r2 t1 t2 #2)
3371 Rows(r2 t1 t2 t3 #2)
3372 Rows(r2 t1 t2 t3 t4 #2)
3373 not used hint:
3374 duplication hint:
3375 error hint:
3376
3377 LOG:  pg_hint_plan:
3378 used hint:
3379 Leading(r2 t1 t2 t3 t4)
3380 Rows(r2 t1 #2)
3381 Rows(r2 t1 t2 #2)
3382 Rows(r2 t1 t2 t3 #2)
3383 Rows(r2 t1 t2 t3 t4 #2)
3384 not used hint:
3385 duplication hint:
3386 error hint:
3387
3388 \o
3389 \! sql/maskout.sh results/ut-R.tmpout
3390                                    QUERY PLAN                                    
3391 ---------------------------------------------------------------------------------
3392  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3393    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3394          Join Filter: (t1.c1 = t4.c1)
3395          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3396                TID Cond: (ctid = '(1,1)'::tid)
3397          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3398                Join Filter: (t1.c1 = t3.c1)
3399                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3400                      TID Cond: (ctid = '(1,1)'::tid)
3401                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3402                      Join Filter: (t1.c1 = t2.c1)
3403                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3404                            Filter: (ctid = '(1,1)'::tid)
3405                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3406                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3407                                  TID Cond: (ctid = '(1,1)'::tid)
3408                            ->  Seq Scan on r2  (cost=xxx..xxx rows=6 width=xxx)
3409                                  Filter: (c1 = 1)
3410  
3411  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3412    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3413          Join Filter: (t1.c1 = t4.c1)
3414          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3415                TID Cond: (ctid = '(1,1)'::tid)
3416          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3417                Join Filter: (t1.c1 = t3.c1)
3418                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3419                      TID Cond: (ctid = '(1,1)'::tid)
3420                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3421                      Join Filter: (t1.c1 = t2.c1)
3422                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3423                            Filter: (ctid = '(1,1)'::tid)
3424                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3425                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3426                                  TID Cond: (ctid = '(1,1)'::tid)
3427                            ->  Seq Scan on r2  (cost=xxx..xxx rows=6 width=xxx)
3428                                  Filter: (c1 = 1)
3429
3430 \o results/ut-R.tmpout
3431 /*+
3432 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3433 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3434 */
3435 EXPLAIN UPDATE s1.r2_ SET c1 = c1 WHERE c1 = 1;
3436 LOG:  pg_hint_plan:
3437 used hint:
3438 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3439 not used hint:
3440 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3441 duplication hint:
3442 error hint:
3443
3444 LOG:  pg_hint_plan:
3445 used hint:
3446 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3447 not used hint:
3448 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3449 duplication hint:
3450 error hint:
3451
3452 \o
3453 \! sql/maskout.sh results/ut-R.tmpout
3454                                              QUERY PLAN                                             
3455 ----------------------------------------------------------------------------------------------------
3456  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3457    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3458          Join Filter: (b1t1.c1 = b1t4.c1)
3459          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3460                Join Filter: (b1t1.c1 = b1t3.c1)
3461                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3462                      Merge Cond: (b1t1.c1 = b1t2.c1)
3463                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3464                            ->  Index Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3465                                  Filter: (ctid = '(1,1)'::tid)
3466                            ->  Seq Scan on r2_  (cost=xxx..xxx rows=6 width=xxx)
3467                                  Filter: (c1 = 1)
3468                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3469                            Sort Key: b1t2.c1
3470                            ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3471                                  Filter: (ctid = '(1,1)'::tid)
3472                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3473                      TID Cond: (ctid = '(1,1)'::tid)
3474          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3475                TID Cond: (ctid = '(1,1)'::tid)
3476  
3477  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3478    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3479          Join Filter: (b2t1.c1 = b2t4.c1)
3480          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3481                Join Filter: (b2t1.c1 = b2t3.c1)
3482                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3483                      Merge Cond: (b2t1.c1 = b2t2.c1)
3484                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3485                            ->  Index Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
3486                                  Filter: (ctid = '(1,1)'::tid)
3487                            ->  Seq Scan on r2_  (cost=xxx..xxx rows=6 width=xxx)
3488                                  Filter: (c1 = 1)
3489                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3490                            Sort Key: b2t2.c1
3491                            ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
3492                                  Filter: (ctid = '(1,1)'::tid)
3493                ->  Tid Scan on t3 b2t3  (cost=xxx..xxx rows=1 width=xxx)
3494                      TID Cond: (ctid = '(1,1)'::tid)
3495          ->  Tid Scan on t4 b2t4  (cost=xxx..xxx rows=1 width=xxx)
3496                TID Cond: (ctid = '(1,1)'::tid)
3497
3498 \o results/ut-R.tmpout
3499 /*+
3500 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3501 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3502 Rows(r2_ b1t1 #2)
3503 Rows(r2_ b1t1 b1t2 #2)
3504 Rows(r2_ b1t1 b1t2 b1t3 #2)
3505 Rows(r2_ b1t1 b1t2 b1t3 b1t4 #2)
3506 Rows(r2_ b2t1 #2)
3507 Rows(r2_ b2t1 b2t2 #2)
3508 Rows(r2_ b2t1 b2t2 b2t3  #2)
3509 Rows(r2_ b2t1 b2t2 b2t3 b2t4 #2)
3510 */
3511 EXPLAIN UPDATE s1.r2_ SET c1 = c1 WHERE c1 = 1;
3512 LOG:  pg_hint_plan:
3513 used hint:
3514 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3515 Rows(b1t1 r2_ #2)
3516 Rows(b1t1 b1t2 r2_ #2)
3517 Rows(b1t1 b1t2 b1t3 r2_ #2)
3518 Rows(b1t1 b1t2 b1t3 b1t4 r2_ #2)
3519 not used hint:
3520 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3521 Rows(b2t1 r2_ #2)
3522 Rows(b2t1 b2t2 r2_ #2)
3523 Rows(b2t1 b2t2 b2t3 r2_ #2)
3524 Rows(b2t1 b2t2 b2t3 b2t4 r2_ #2)
3525 duplication hint:
3526 error hint:
3527
3528 LOG:  pg_hint_plan:
3529 used hint:
3530 Leading(r2_ b2t1 b2t2 b2t3 b2t4)
3531 Rows(b2t1 r2_ #2)
3532 Rows(b2t1 b2t2 r2_ #2)
3533 Rows(b2t1 b2t2 b2t3 r2_ #2)
3534 Rows(b2t1 b2t2 b2t3 b2t4 r2_ #2)
3535 not used hint:
3536 Leading(r2_ b1t1 b1t2 b1t3 b1t4)
3537 Rows(b1t1 r2_ #2)
3538 Rows(b1t1 b1t2 r2_ #2)
3539 Rows(b1t1 b1t2 b1t3 r2_ #2)
3540 Rows(b1t1 b1t2 b1t3 b1t4 r2_ #2)
3541 duplication hint:
3542 error hint:
3543
3544 \o
3545 \! sql/maskout.sh results/ut-R.tmpout
3546                                      QUERY PLAN                                      
3547 -------------------------------------------------------------------------------------
3548  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3549    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3550          Join Filter: (b1t1.c1 = b1t4.c1)
3551          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3552                TID Cond: (ctid = '(1,1)'::tid)
3553          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3554                Join Filter: (b1t1.c1 = b1t3.c1)
3555                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3556                      TID Cond: (ctid = '(1,1)'::tid)
3557                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3558                      Join Filter: (b1t1.c1 = b1t2.c1)
3559                      ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3560                            Filter: (ctid = '(1,1)'::tid)
3561                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3562                            ->  Tid Scan on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3563                                  TID Cond: (ctid = '(1,1)'::tid)
3564                            ->  Seq Scan on r2_  (cost=xxx..xxx rows=6 width=xxx)
3565                                  Filter: (c1 = 1)
3566  
3567  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3568    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3569          Join Filter: (b2t1.c1 = b2t4.c1)
3570          ->  Tid Scan on t4 b2t4  (cost=xxx..xxx rows=1 width=xxx)
3571                TID Cond: (ctid = '(1,1)'::tid)
3572          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3573                Join Filter: (b2t1.c1 = b2t3.c1)
3574                ->  Tid Scan on t3 b2t3  (cost=xxx..xxx rows=1 width=xxx)
3575                      TID Cond: (ctid = '(1,1)'::tid)
3576                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3577                      Join Filter: (b2t1.c1 = b2t2.c1)
3578                      ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
3579                            Filter: (ctid = '(1,1)'::tid)
3580                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3581                            ->  Tid Scan on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
3582                                  TID Cond: (ctid = '(1,1)'::tid)
3583                            ->  Seq Scan on r2_  (cost=xxx..xxx rows=6 width=xxx)
3584                                  Filter: (c1 = 1)
3585
3586 -- No. R-2-3-3
3587 \o results/ut-R.tmpout
3588 /*+
3589 Leading(r3 t1 t2 t3 t4)
3590 */
3591 EXPLAIN UPDATE s1.r3 SET c1 = c1 WHERE c1 = 1;
3592 LOG:  pg_hint_plan:
3593 used hint:
3594 Leading(r3 t1 t2 t3 t4)
3595 not used hint:
3596 duplication hint:
3597 error hint:
3598
3599 LOG:  pg_hint_plan:
3600 used hint:
3601 Leading(r3 t1 t2 t3 t4)
3602 not used hint:
3603 duplication hint:
3604 error hint:
3605
3606 LOG:  pg_hint_plan:
3607 used hint:
3608 Leading(r3 t1 t2 t3 t4)
3609 not used hint:
3610 duplication hint:
3611 error hint:
3612
3613 \o
3614 \! sql/maskout.sh results/ut-R.tmpout
3615                                           QUERY PLAN                                           
3616 -----------------------------------------------------------------------------------------------
3617  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3618    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3619          Join Filter: (t1.c1 = t4.c1)
3620          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3621                Join Filter: (t1.c1 = t3.c1)
3622                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3623                      Merge Cond: (t1.c1 = t2.c1)
3624                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3625                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3626                                  Filter: (ctid = '(1,1)'::tid)
3627                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3628                                  Filter: (c1 = 1)
3629                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3630                            Sort Key: t2.c1
3631                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3632                                  Filter: (ctid = '(1,1)'::tid)
3633                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3634                      TID Cond: (ctid = '(1,1)'::tid)
3635          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3636                TID Cond: (ctid = '(1,1)'::tid)
3637  
3638  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3639    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3640          Join Filter: (t1.c1 = t4.c1)
3641          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3642                Join Filter: (t1.c1 = t3.c1)
3643                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3644                      Merge Cond: (t1.c1 = t2.c1)
3645                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3646                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3647                                  Filter: (ctid = '(1,1)'::tid)
3648                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3649                                  Filter: (c1 = 1)
3650                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3651                            Sort Key: t2.c1
3652                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3653                                  Filter: (ctid = '(1,1)'::tid)
3654                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3655                      TID Cond: (ctid = '(1,1)'::tid)
3656          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3657                TID Cond: (ctid = '(1,1)'::tid)
3658  
3659  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3660    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3661          Join Filter: (t1.c1 = t4.c1)
3662          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3663                Join Filter: (t1.c1 = t3.c1)
3664                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3665                      Merge Cond: (t1.c1 = t2.c1)
3666                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3667                            ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
3668                                  Filter: (ctid = '(1,1)'::tid)
3669                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3670                                  Filter: (c1 = 1)
3671                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3672                            Sort Key: t2.c1
3673                            ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3674                                  Filter: (ctid = '(1,1)'::tid)
3675                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3676                      TID Cond: (ctid = '(1,1)'::tid)
3677          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3678                TID Cond: (ctid = '(1,1)'::tid)
3679
3680 \o results/ut-R.tmpout
3681 /*+
3682 Leading(r3 t1 t2 t3 t4)
3683 Rows(r3 t1 t2 t3 t4 #2)
3684 Rows(r3 t1 t2 t3 #2)
3685 Rows(r3 t1 t2 #2)
3686 Rows(r3 t1 #2)
3687 */
3688 EXPLAIN UPDATE s1.r3 SET c1 = c1 WHERE c1 = 1;
3689 LOG:  pg_hint_plan:
3690 used hint:
3691 Leading(r3 t1 t2 t3 t4)
3692 Rows(r3 t1 #2)
3693 Rows(r3 t1 t2 #2)
3694 Rows(r3 t1 t2 t3 #2)
3695 Rows(r3 t1 t2 t3 t4 #2)
3696 not used hint:
3697 duplication hint:
3698 error hint:
3699
3700 LOG:  pg_hint_plan:
3701 used hint:
3702 Leading(r3 t1 t2 t3 t4)
3703 Rows(r3 t1 #2)
3704 Rows(r3 t1 t2 #2)
3705 Rows(r3 t1 t2 t3 #2)
3706 Rows(r3 t1 t2 t3 t4 #2)
3707 not used hint:
3708 duplication hint:
3709 error hint:
3710
3711 LOG:  pg_hint_plan:
3712 used hint:
3713 Leading(r3 t1 t2 t3 t4)
3714 Rows(r3 t1 #2)
3715 Rows(r3 t1 t2 #2)
3716 Rows(r3 t1 t2 t3 #2)
3717 Rows(r3 t1 t2 t3 t4 #2)
3718 not used hint:
3719 duplication hint:
3720 error hint:
3721
3722 \o
3723 \! sql/maskout.sh results/ut-R.tmpout
3724                                    QUERY PLAN                                    
3725 ---------------------------------------------------------------------------------
3726  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3727    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3728          Join Filter: (t1.c1 = t4.c1)
3729          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3730                TID Cond: (ctid = '(1,1)'::tid)
3731          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3732                Join Filter: (t1.c1 = t3.c1)
3733                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3734                      TID Cond: (ctid = '(1,1)'::tid)
3735                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3736                      Join Filter: (t1.c1 = t2.c1)
3737                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3738                            Filter: (ctid = '(1,1)'::tid)
3739                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3740                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3741                                  TID Cond: (ctid = '(1,1)'::tid)
3742                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3743                                  Filter: (c1 = 1)
3744  
3745  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3746    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3747          Join Filter: (t1.c1 = t4.c1)
3748          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3749                TID Cond: (ctid = '(1,1)'::tid)
3750          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3751                Join Filter: (t1.c1 = t3.c1)
3752                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3753                      TID Cond: (ctid = '(1,1)'::tid)
3754                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3755                      Join Filter: (t1.c1 = t2.c1)
3756                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3757                            Filter: (ctid = '(1,1)'::tid)
3758                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3759                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3760                                  TID Cond: (ctid = '(1,1)'::tid)
3761                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3762                                  Filter: (c1 = 1)
3763  
3764  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3765    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3766          Join Filter: (t1.c1 = t4.c1)
3767          ->  Tid Scan on t4  (cost=xxx..xxx rows=1 width=xxx)
3768                TID Cond: (ctid = '(1,1)'::tid)
3769          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3770                Join Filter: (t1.c1 = t3.c1)
3771                ->  Tid Scan on t3  (cost=xxx..xxx rows=1 width=xxx)
3772                      TID Cond: (ctid = '(1,1)'::tid)
3773                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3774                      Join Filter: (t1.c1 = t2.c1)
3775                      ->  Seq Scan on t2  (cost=xxx..xxx rows=1 width=xxx)
3776                            Filter: (ctid = '(1,1)'::tid)
3777                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3778                            ->  Tid Scan on t1  (cost=xxx..xxx rows=1 width=xxx)
3779                                  TID Cond: (ctid = '(1,1)'::tid)
3780                            ->  Seq Scan on r3  (cost=xxx..xxx rows=6 width=xxx)
3781                                  Filter: (c1 = 1)
3782
3783 \o results/ut-R.tmpout
3784 /*+
3785 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3786 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3787 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3788 */
3789 EXPLAIN UPDATE s1.r3_ SET c1 = c1 WHERE c1 = 1;
3790 LOG:  pg_hint_plan:
3791 used hint:
3792 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3793 not used hint:
3794 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3795 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3796 duplication hint:
3797 error hint:
3798
3799 LOG:  pg_hint_plan:
3800 used hint:
3801 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3802 not used hint:
3803 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3804 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3805 duplication hint:
3806 error hint:
3807
3808 LOG:  pg_hint_plan:
3809 used hint:
3810 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3811 not used hint:
3812 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3813 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3814 duplication hint:
3815 error hint:
3816
3817 \o
3818 \! sql/maskout.sh results/ut-R.tmpout
3819                                              QUERY PLAN                                             
3820 ----------------------------------------------------------------------------------------------------
3821  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3822    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3823          Join Filter: (b1t1.c1 = b1t4.c1)
3824          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3825                Join Filter: (b1t1.c1 = b1t3.c1)
3826                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3827                      Merge Cond: (b1t1.c1 = b1t2.c1)
3828                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3829                            ->  Index Scan using t1_i1 on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3830                                  Filter: (ctid = '(1,1)'::tid)
3831                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
3832                                  Filter: (c1 = 1)
3833                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3834                            Sort Key: b1t2.c1
3835                            ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3836                                  Filter: (ctid = '(1,1)'::tid)
3837                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3838                      TID Cond: (ctid = '(1,1)'::tid)
3839          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3840                TID Cond: (ctid = '(1,1)'::tid)
3841  
3842  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3843    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3844          Join Filter: (b2t1.c1 = b2t4.c1)
3845          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3846                Join Filter: (b2t1.c1 = b2t3.c1)
3847                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3848                      Merge Cond: (b2t1.c1 = b2t2.c1)
3849                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3850                            ->  Index Scan using t1_i1 on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
3851                                  Filter: (ctid = '(1,1)'::tid)
3852                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
3853                                  Filter: (c1 = 1)
3854                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3855                            Sort Key: b2t2.c1
3856                            ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
3857                                  Filter: (ctid = '(1,1)'::tid)
3858                ->  Tid Scan on t3 b2t3  (cost=xxx..xxx rows=1 width=xxx)
3859                      TID Cond: (ctid = '(1,1)'::tid)
3860          ->  Tid Scan on t4 b2t4  (cost=xxx..xxx rows=1 width=xxx)
3861                TID Cond: (ctid = '(1,1)'::tid)
3862  
3863  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3864    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3865          Join Filter: (b3t1.c1 = b3t4.c1)
3866          ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
3867                Join Filter: (b3t1.c1 = b3t3.c1)
3868                ->  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
3869                      Merge Cond: (b3t1.c1 = b3t2.c1)
3870                      ->  Nested Loop  (cost=xxx..xxx rows=6 width=xxx)
3871                            ->  Index Scan using t1_i1 on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
3872                                  Filter: (ctid = '(1,1)'::tid)
3873                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
3874                                  Filter: (c1 = 1)
3875                      ->  Sort  (cost=xxx..xxx rows=1 width=xxx)
3876                            Sort Key: b3t2.c1
3877                            ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
3878                                  Filter: (ctid = '(1,1)'::tid)
3879                ->  Tid Scan on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
3880                      TID Cond: (ctid = '(1,1)'::tid)
3881          ->  Tid Scan on t4 b3t4  (cost=xxx..xxx rows=1 width=xxx)
3882                TID Cond: (ctid = '(1,1)'::tid)
3883
3884 \o results/ut-R.tmpout
3885 /*+
3886 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3887 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3888 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3889 Rows(r3_ b1t1 #2)
3890 Rows(r3_ b1t1 b1t2 #2)
3891 Rows(r3_ b1t1 b1t2 b1t3 #2)
3892 Rows(r3_ b1t1 b1t2 b1t3 b1t4 #2)
3893 Rows(r3_ b2t1 #2)
3894 Rows(r3_ b2t1 b2t2 #2)
3895 Rows(r3_ b2t1 b2t2 b2t3 #2)
3896 Rows(r3_ b2t1 b2t2 b2t3 b2t4 #2)
3897 Rows(r3_ b3t1 #2)
3898 Rows(r3_ b3t1 b3t2 #2)
3899 Rows(r3_ b3t1 b3t2 b3t3 #2)
3900 Rows(r3_ b3t1 b3t2 b3t3 b3t4 #2)
3901 */
3902 EXPLAIN UPDATE s1.r3_ SET c1 = c1 WHERE c1 = 1;
3903 LOG:  pg_hint_plan:
3904 used hint:
3905 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3906 Rows(b1t1 r3_ #2)
3907 Rows(b1t1 b1t2 r3_ #2)
3908 Rows(b1t1 b1t2 b1t3 r3_ #2)
3909 Rows(b1t1 b1t2 b1t3 b1t4 r3_ #2)
3910 not used hint:
3911 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3912 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3913 Rows(b2t1 r3_ #2)
3914 Rows(b3t1 r3_ #2)
3915 Rows(b2t1 b2t2 r3_ #2)
3916 Rows(b3t1 b3t2 r3_ #2)
3917 Rows(b2t1 b2t2 b2t3 r3_ #2)
3918 Rows(b3t1 b3t2 b3t3 r3_ #2)
3919 Rows(b2t1 b2t2 b2t3 b2t4 r3_ #2)
3920 Rows(b3t1 b3t2 b3t3 b3t4 r3_ #2)
3921 duplication hint:
3922 error hint:
3923
3924 LOG:  pg_hint_plan:
3925 used hint:
3926 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3927 Rows(b2t1 r3_ #2)
3928 Rows(b2t1 b2t2 r3_ #2)
3929 Rows(b2t1 b2t2 b2t3 r3_ #2)
3930 Rows(b2t1 b2t2 b2t3 b2t4 r3_ #2)
3931 not used hint:
3932 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3933 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3934 Rows(b1t1 r3_ #2)
3935 Rows(b3t1 r3_ #2)
3936 Rows(b1t1 b1t2 r3_ #2)
3937 Rows(b3t1 b3t2 r3_ #2)
3938 Rows(b1t1 b1t2 b1t3 r3_ #2)
3939 Rows(b3t1 b3t2 b3t3 r3_ #2)
3940 Rows(b1t1 b1t2 b1t3 b1t4 r3_ #2)
3941 Rows(b3t1 b3t2 b3t3 b3t4 r3_ #2)
3942 duplication hint:
3943 error hint:
3944
3945 LOG:  pg_hint_plan:
3946 used hint:
3947 Leading(r3_ b3t1 b3t2 b3t3 b3t4)
3948 Rows(b3t1 r3_ #2)
3949 Rows(b3t1 b3t2 r3_ #2)
3950 Rows(b3t1 b3t2 b3t3 r3_ #2)
3951 Rows(b3t1 b3t2 b3t3 b3t4 r3_ #2)
3952 not used hint:
3953 Leading(r3_ b1t1 b1t2 b1t3 b1t4)
3954 Leading(r3_ b2t1 b2t2 b2t3 b2t4)
3955 Rows(b1t1 r3_ #2)
3956 Rows(b2t1 r3_ #2)
3957 Rows(b1t1 b1t2 r3_ #2)
3958 Rows(b2t1 b2t2 r3_ #2)
3959 Rows(b1t1 b1t2 b1t3 r3_ #2)
3960 Rows(b2t1 b2t2 b2t3 r3_ #2)
3961 Rows(b1t1 b1t2 b1t3 b1t4 r3_ #2)
3962 Rows(b2t1 b2t2 b2t3 b2t4 r3_ #2)
3963 duplication hint:
3964 error hint:
3965
3966 \o
3967 \! sql/maskout.sh results/ut-R.tmpout
3968                                      QUERY PLAN                                      
3969 -------------------------------------------------------------------------------------
3970  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3971    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3972          Join Filter: (b1t1.c1 = b1t4.c1)
3973          ->  Tid Scan on t4 b1t4  (cost=xxx..xxx rows=1 width=xxx)
3974                TID Cond: (ctid = '(1,1)'::tid)
3975          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3976                Join Filter: (b1t1.c1 = b1t3.c1)
3977                ->  Tid Scan on t3 b1t3  (cost=xxx..xxx rows=1 width=xxx)
3978                      TID Cond: (ctid = '(1,1)'::tid)
3979                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3980                      Join Filter: (b1t1.c1 = b1t2.c1)
3981                      ->  Seq Scan on t2 b1t2  (cost=xxx..xxx rows=1 width=xxx)
3982                            Filter: (ctid = '(1,1)'::tid)
3983                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3984                            ->  Tid Scan on t1 b1t1  (cost=xxx..xxx rows=1 width=xxx)
3985                                  TID Cond: (ctid = '(1,1)'::tid)
3986                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
3987                                  Filter: (c1 = 1)
3988  
3989  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
3990    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3991          Join Filter: (b2t1.c1 = b2t4.c1)
3992          ->  Tid Scan on t4 b2t4  (cost=xxx..xxx rows=1 width=xxx)
3993                TID Cond: (ctid = '(1,1)'::tid)
3994          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3995                Join Filter: (b2t1.c1 = b2t3.c1)
3996                ->  Tid Scan on t3 b2t3  (cost=xxx..xxx rows=1 width=xxx)
3997                      TID Cond: (ctid = '(1,1)'::tid)
3998                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
3999                      Join Filter: (b2t1.c1 = b2t2.c1)
4000                      ->  Seq Scan on t2 b2t2  (cost=xxx..xxx rows=1 width=xxx)
4001                            Filter: (ctid = '(1,1)'::tid)
4002                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4003                            ->  Tid Scan on t1 b2t1  (cost=xxx..xxx rows=1 width=xxx)
4004                                  TID Cond: (ctid = '(1,1)'::tid)
4005                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
4006                                  Filter: (c1 = 1)
4007  
4008  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
4009    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4010          Join Filter: (b3t1.c1 = b3t4.c1)
4011          ->  Tid Scan on t4 b3t4  (cost=xxx..xxx rows=1 width=xxx)
4012                TID Cond: (ctid = '(1,1)'::tid)
4013          ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4014                Join Filter: (b3t1.c1 = b3t3.c1)
4015                ->  Tid Scan on t3 b3t3  (cost=xxx..xxx rows=1 width=xxx)
4016                      TID Cond: (ctid = '(1,1)'::tid)
4017                ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4018                      Join Filter: (b3t1.c1 = b3t2.c1)
4019                      ->  Seq Scan on t2 b3t2  (cost=xxx..xxx rows=1 width=xxx)
4020                            Filter: (ctid = '(1,1)'::tid)
4021                      ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4022                            ->  Tid Scan on t1 b3t1  (cost=xxx..xxx rows=1 width=xxx)
4023                                  TID Cond: (ctid = '(1,1)'::tid)
4024                            ->  Seq Scan on r3_  (cost=xxx..xxx rows=6 width=xxx)
4025                                  Filter: (c1 = 1)
4026
4027 -- No. R-2-3-4
4028 \o results/ut-R.tmpout
4029 /*+HashJoin(v1t1 v1t1)*/
4030 EXPLAIN SELECT * FROM s1.v1 v1, s1.v1 v2 WHERE v1.c1 = v2.c1;
4031 INFO:  pg_hint_plan: hint syntax error at or near "HashJoin(v1t1 v1t1)"
4032 DETAIL:  Relation name "v1t1" is ambiguous.
4033 LOG:  pg_hint_plan:
4034 used hint:
4035 not used hint:
4036 duplication hint:
4037 error hint:
4038 HashJoin(v1t1 v1t1)
4039
4040 \o
4041 \! sql/maskout.sh results/ut-R.tmpout
4042                                 QUERY PLAN                                
4043 --------------------------------------------------------------------------
4044  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
4045    Hash Cond: (v1t1.c1 = v1t1_1.c1)
4046    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
4047    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
4048          ->  Seq Scan on t1 v1t1_1  (cost=xxx..xxx rows=1000 width=xxx)
4049
4050 \o results/ut-R.tmpout
4051 /*+HashJoin(v1t1 v1t1)Rows(v1t1 v1t1 #1)*/
4052 EXPLAIN SELECT * FROM s1.v1 v1, s1.v1 v2 WHERE v1.c1 = v2.c1;
4053 INFO:  pg_hint_plan: hint syntax error at or near "HashJoin(v1t1 v1t1)Rows(v1t1 v1t1 #1)"
4054 DETAIL:  Relation name "v1t1" is ambiguous.
4055 INFO:  pg_hint_plan: hint syntax error at or near "Rows(v1t1 v1t1 #1)"
4056 DETAIL:  Relation name "v1t1" is ambiguous.
4057 LOG:  pg_hint_plan:
4058 used hint:
4059 not used hint:
4060 duplication hint:
4061 error hint:
4062 HashJoin(v1t1 v1t1)
4063 Rows(v1t1 v1t1 #1)
4064
4065 \o
4066 \! sql/maskout.sh results/ut-R.tmpout
4067                                 QUERY PLAN                                
4068 --------------------------------------------------------------------------
4069  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
4070    Hash Cond: (v1t1.c1 = v1t1_1.c1)
4071    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
4072    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
4073          ->  Seq Scan on t1 v1t1_1  (cost=xxx..xxx rows=1000 width=xxx)
4074
4075 -- No. R-2-3-5
4076 \o results/ut-R.tmpout
4077 /*+NestLoop(v1t1 v1t1_)*/
4078 EXPLAIN SELECT * FROM s1.v1 v1, s1.v1_ v2 WHERE v1.c1 = v2.c1;
4079 LOG:  pg_hint_plan:
4080 used hint:
4081 NestLoop(v1t1 v1t1_)
4082 not used hint:
4083 duplication hint:
4084 error hint:
4085
4086 \o
4087 \! sql/maskout.sh results/ut-R.tmpout
4088                                  QUERY PLAN                                  
4089 -----------------------------------------------------------------------------
4090  Nested Loop  (cost=xxx..xxx rows=1000 width=xxx)
4091    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
4092    ->  Index Scan using t1_i1 on t1 v1t1_  (cost=xxx..xxx rows=1 width=xxx)
4093          Index Cond: (c1 = v1t1.c1)
4094
4095 \o results/ut-R.tmpout
4096 /*+NestLoop(v1t1 v1t1_)Rows(v1t1 v1t1_ #1)*/
4097 EXPLAIN SELECT * FROM s1.v1 v1, s1.v1_ v2 WHERE v1.c1 = v2.c1;
4098 LOG:  pg_hint_plan:
4099 used hint:
4100 NestLoop(v1t1 v1t1_)
4101 Rows(v1t1 v1t1_ #1)
4102 not used hint:
4103 duplication hint:
4104 error hint:
4105
4106 \o
4107 \! sql/maskout.sh results/ut-R.tmpout
4108                                  QUERY PLAN                                  
4109 -----------------------------------------------------------------------------
4110  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4111    ->  Seq Scan on t1 v1t1  (cost=xxx..xxx rows=1000 width=xxx)
4112    ->  Index Scan using t1_i1 on t1 v1t1_  (cost=xxx..xxx rows=1 width=xxx)
4113          Index Cond: (c1 = v1t1.c1)
4114
4115 -- No. R-2-3-6
4116 \o results/ut-R.tmpout
4117 /*+RowsHashJoin(r4t1 r4t1)*/
4118 EXPLAIN SELECT * FROM s1.r4 t1, s1.r4 t2 WHERE t1.c1 = t2.c1;
4119 INFO:  pg_hint_plan: hint syntax error at or near "RowsHashJoin(r4t1 r4t1)"
4120 DETAIL:  Unrecognized hint keyword "RowsHashJoin".
4121 \o
4122 \! sql/maskout.sh results/ut-R.tmpout
4123                                 QUERY PLAN                                
4124 --------------------------------------------------------------------------
4125  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
4126    Hash Cond: (r4t1.c1 = r4t1_1.c1)
4127    ->  Seq Scan on t1 r4t1  (cost=xxx..xxx rows=1000 width=xxx)
4128    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
4129          ->  Seq Scan on t1 r4t1_1  (cost=xxx..xxx rows=1000 width=xxx)
4130
4131 \o results/ut-R.tmpout
4132 /*+RowsHashJoin(r4t1 r4t1)Rows(r4t1 r4t1 #1)*/
4133 EXPLAIN SELECT * FROM s1.r4 t1, s1.r4 t2 WHERE t1.c1 = t2.c1;
4134 INFO:  pg_hint_plan: hint syntax error at or near "RowsHashJoin(r4t1 r4t1)Rows(r4t1 r4t1 #1)"
4135 DETAIL:  Unrecognized hint keyword "RowsHashJoin".
4136 \o
4137 \! sql/maskout.sh results/ut-R.tmpout
4138                                 QUERY PLAN                                
4139 --------------------------------------------------------------------------
4140  Hash Join  (cost=xxx..xxx rows=1000 width=xxx)
4141    Hash Cond: (r4t1.c1 = r4t1_1.c1)
4142    ->  Seq Scan on t1 r4t1  (cost=xxx..xxx rows=1000 width=xxx)
4143    ->  Hash  (cost=xxx..xxx rows=1000 width=xxx)
4144          ->  Seq Scan on t1 r4t1_1  (cost=xxx..xxx rows=1000 width=xxx)
4145
4146 -- No. R-2-3-7
4147 \o results/ut-R.tmpout
4148 /*+NestLoop(r4t1 r5t1)*/
4149 EXPLAIN SELECT * FROM s1.r4 t1, s1.r5 t2 WHERE t1.c1 = t2.c1;
4150 LOG:  pg_hint_plan:
4151 used hint:
4152 NestLoop(r4t1 r5t1)
4153 not used hint:
4154 duplication hint:
4155 error hint:
4156
4157 \o
4158 \! sql/maskout.sh results/ut-R.tmpout
4159                                  QUERY PLAN                                 
4160 ----------------------------------------------------------------------------
4161  Nested Loop  (cost=xxx..xxx rows=1000 width=xxx)
4162    ->  Seq Scan on t1 r4t1  (cost=xxx..xxx rows=1000 width=xxx)
4163    ->  Index Scan using t1_i1 on t1 r5t1  (cost=xxx..xxx rows=1 width=xxx)
4164          Index Cond: (c1 = r4t1.c1)
4165
4166 \o results/ut-R.tmpout
4167 /*+NestLoop(r4t1 r5t1)Rows(r4t1 r5t1 #1)*/
4168 EXPLAIN SELECT * FROM s1.r4 t1, s1.r5 t2 WHERE t1.c1 = t2.c1;
4169 LOG:  pg_hint_plan:
4170 used hint:
4171 NestLoop(r4t1 r5t1)
4172 Rows(r4t1 r5t1 #1)
4173 not used hint:
4174 duplication hint:
4175 error hint:
4176
4177 \o
4178 \! sql/maskout.sh results/ut-R.tmpout
4179                                  QUERY PLAN                                 
4180 ----------------------------------------------------------------------------
4181  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4182    ->  Seq Scan on t1 r4t1  (cost=xxx..xxx rows=1000 width=xxx)
4183    ->  Index Scan using t1_i1 on t1 r5t1  (cost=xxx..xxx rows=1 width=xxx)
4184          Index Cond: (c1 = r4t1.c1)
4185
4186 ----
4187 ---- No. R-2-4 VALUES clause
4188 ----
4189 -- No. R-2-4-1
4190 \o results/ut-R.tmpout
4191 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
4192 \o
4193 \! sql/maskout.sh results/ut-R.tmpout
4194                                    QUERY PLAN                                   
4195 --------------------------------------------------------------------------------
4196  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4197    ->  Hash Join  (cost=xxx..xxx rows=2 width=xxx)
4198          Hash Cond: (t2.c1 = "*VALUES*".column1)
4199          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4200          ->  Hash  (cost=xxx..xxx rows=2 width=xxx)
4201                ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4202    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4203          Index Cond: (c1 = t2.c1)
4204
4205 \o results/ut-R.tmpout
4206 /*+ Leading(t3 t1 t2) Rows(t3 t1 #2)Rows(t3 t1 t2 #2)*/
4207 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
4208 LOG:  pg_hint_plan:
4209 used hint:
4210 not used hint:
4211 Leading(t3 t1 t2)
4212 Rows(t1 t3 #2)
4213 Rows(t1 t2 t3 #2)
4214 duplication hint:
4215 error hint:
4216
4217 \o
4218 \! sql/maskout.sh results/ut-R.tmpout
4219                                    QUERY PLAN                                   
4220 --------------------------------------------------------------------------------
4221  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4222    ->  Hash Join  (cost=xxx..xxx rows=2 width=xxx)
4223          Hash Cond: (t2.c1 = "*VALUES*".column1)
4224          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4225          ->  Hash  (cost=xxx..xxx rows=2 width=xxx)
4226                ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4227    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4228          Index Cond: (c1 = t2.c1)
4229
4230 \o results/ut-R.tmpout
4231 /*+ Leading(*VALUES* t1 t2) Rows(*VALUES* t1 #2)Rows(*VALUES* t1 t2 #20)*/
4232 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
4233 LOG:  pg_hint_plan:
4234 used hint:
4235 Leading(*VALUES* t1 t2)
4236 Rows(*VALUES* t1 #2)
4237 Rows(*VALUES* t1 t2 #20)
4238 not used hint:
4239 duplication hint:
4240 error hint:
4241
4242 \o
4243 \! sql/maskout.sh results/ut-R.tmpout
4244                                  QUERY PLAN                                  
4245 -----------------------------------------------------------------------------
4246  Nested Loop  (cost=xxx..xxx rows=20 width=xxx)
4247    ->  Nested Loop  (cost=xxx..xxx rows=2 width=xxx)
4248          ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4249          ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4250                Index Cond: (c1 = "*VALUES*".column1)
4251    ->  Index Scan using t2_i1 on t2  (cost=xxx..xxx rows=1 width=xxx)
4252          Index Cond: (c1 = t1.c1)
4253
4254 -- No. R-2-4-2
4255 \o results/ut-R.tmpout
4256 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t4 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
4257 \o
4258 \! sql/maskout.sh results/ut-R.tmpout
4259                                       QUERY PLAN                                      
4260 --------------------------------------------------------------------------------------
4261  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4262    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4263          Join Filter: (t2.c1 = "*VALUES*_1".column1)
4264          ->  Hash Join  (cost=xxx..xxx rows=2 width=xxx)
4265                Hash Cond: (t2.c1 = "*VALUES*".column1)
4266                ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4267                ->  Hash  (cost=xxx..xxx rows=2 width=xxx)
4268                      ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4269          ->  Materialize  (cost=xxx..xxx rows=2 width=xxx)
4270                ->  Values Scan on "*VALUES*_1"  (cost=xxx..xxx rows=2 width=xxx)
4271    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4272          Index Cond: (c1 = t2.c1)
4273
4274 \o results/ut-R.tmpout
4275 /*+ Leading(t4 t3 t2 t1) Rows(t4 t3 #2) Rows(t4 t3 t2 #2)Rows(t4 t3 t2 t1 #2)*/
4276 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t4 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
4277 LOG:  pg_hint_plan:
4278 used hint:
4279 not used hint:
4280 Leading(t4 t3 t2 t1)
4281 Rows(t3 t4 #2)
4282 Rows(t2 t3 t4 #2)
4283 Rows(t1 t2 t3 t4 #2)
4284 duplication hint:
4285 error hint:
4286
4287 \o
4288 \! sql/maskout.sh results/ut-R.tmpout
4289                                       QUERY PLAN                                      
4290 --------------------------------------------------------------------------------------
4291  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4292    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4293          Join Filter: (t2.c1 = "*VALUES*_1".column1)
4294          ->  Hash Join  (cost=xxx..xxx rows=2 width=xxx)
4295                Hash Cond: (t2.c1 = "*VALUES*".column1)
4296                ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4297                ->  Hash  (cost=xxx..xxx rows=2 width=xxx)
4298                      ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4299          ->  Materialize  (cost=xxx..xxx rows=2 width=xxx)
4300                ->  Values Scan on "*VALUES*_1"  (cost=xxx..xxx rows=2 width=xxx)
4301    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4302          Index Cond: (c1 = t2.c1)
4303
4304 \o results/ut-R.tmpout
4305 /*+ Leading(*VALUES* t3 t2 t1) Rows(t4 t3 #2)Rows(*VALUES* t3 t2 #2)Rows(*VALUES* t3 t2 t1 #2)*/
4306 EXPLAIN SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t4 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
4307 INFO:  pg_hint_plan: hint syntax error at or near "Rows(*VALUES* t3 t2 #2)Rows(*VALUES* t3 t2 t1 #2)"
4308 DETAIL:  Relation name "*VALUES*" is ambiguous.
4309 INFO:  pg_hint_plan: hint syntax error at or near "Rows(*VALUES* t3 t2 t1 #2)"
4310 DETAIL:  Relation name "*VALUES*" is ambiguous.
4311 INFO:  pg_hint_plan: hint syntax error at or near "Leading(*VALUES* t3 t2 t1) Rows(t4 t3 #2)Rows(*VALUES* t3 t2 #2)Rows(*VALUES* t3 t2 t1 #2)"
4312 DETAIL:  Relation name "*VALUES*" is ambiguous.
4313 LOG:  pg_hint_plan:
4314 used hint:
4315 not used hint:
4316 Rows(t3 t4 #2)
4317 duplication hint:
4318 error hint:
4319 Leading(*VALUES* t3 t2 t1)
4320 Rows(*VALUES* t2 t3 #2)
4321 Rows(*VALUES* t1 t2 t3 #2)
4322
4323 \o
4324 \! sql/maskout.sh results/ut-R.tmpout
4325                                       QUERY PLAN                                      
4326 --------------------------------------------------------------------------------------
4327  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4328    ->  Nested Loop  (cost=xxx..xxx rows=1 width=xxx)
4329          Join Filter: (t2.c1 = "*VALUES*_1".column1)
4330          ->  Hash Join  (cost=xxx..xxx rows=2 width=xxx)
4331                Hash Cond: (t2.c1 = "*VALUES*".column1)
4332                ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4333                ->  Hash  (cost=xxx..xxx rows=2 width=xxx)
4334                      ->  Values Scan on "*VALUES*"  (cost=xxx..xxx rows=2 width=xxx)
4335          ->  Materialize  (cost=xxx..xxx rows=2 width=xxx)
4336                ->  Values Scan on "*VALUES*_1"  (cost=xxx..xxx rows=2 width=xxx)
4337    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1 width=xxx)
4338          Index Cond: (c1 = t2.c1)
4339
4340 ----
4341 ---- No. R-2-5
4342 ----
4343 -- No. R-2-5-1
4344 \o results/ut-R.tmpout
4345 EXPLAIN SELECT max(bmt1.c1) FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4346 \o
4347 \! sql/maskout.sh results/ut-R.tmpout
4348                                               QUERY PLAN                                              
4349 ------------------------------------------------------------------------------------------------------
4350  Aggregate  (cost=xxx..xxx rows=1 width=xxx)
4351    ->  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
4352          ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4353                Merge Cond: (bmt1.c1 = bmt2.c1)
4354                ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
4355                      Merge Cond: (bmt1.c1 = bmt3.c1)
4356                      ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4357                      ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4358                ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4359                      Sort Key: bmt2.c1
4360                      ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4361          ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
4362                Index Cond: (c1 = bmt1.c1)
4363
4364 \o results/ut-R.tmpout
4365 /*+
4366 Leading(bmt4 bmt3 bmt2 bmt1)
4367 Rows(bmt1 bmt2 bmt3 bmt4 *0.7)
4368 */
4369 EXPLAIN SELECT bmt1.c1 FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4370 LOG:  pg_hint_plan:
4371 used hint:
4372 Leading(bmt4 bmt3 bmt2 bmt1)
4373 Rows(bmt1 bmt2 bmt3 bmt4 *0.7)
4374 not used hint:
4375 duplication hint:
4376 error hint:
4377
4378 \o
4379 \! sql/maskout.sh results/ut-R.tmpout
4380                                        QUERY PLAN                                        
4381 -----------------------------------------------------------------------------------------
4382  Merge Join  (cost=xxx..xxx rows=70 width=xxx)
4383    Merge Cond: (bmt1.c1 = bmt2.c1)
4384    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4385    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4386          Sort Key: bmt2.c1
4387          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
4388                Hash Cond: (bmt3.c1 = bmt2.c1)
4389                ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
4390                      Hash Cond: (bmt3.c1 = bmt4.c1)
4391                      ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4392                      ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
4393                            ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
4394                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
4395                      ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4396
4397 -- No. R-2-5-2
4398 \o results/ut-R.tmpout
4399 EXPLAIN SELECT bmt1.c1 FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4400 \o
4401 \! sql/maskout.sh results/ut-R.tmpout
4402                                            QUERY PLAN                                           
4403 ------------------------------------------------------------------------------------------------
4404  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
4405    ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4406          Merge Cond: (bmt1.c1 = bmt2.c1)
4407          ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
4408                Merge Cond: (bmt1.c1 = bmt3.c1)
4409                ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4410                ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4411          ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4412                Sort Key: bmt2.c1
4413                ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4414    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
4415          Index Cond: (c1 = bmt1.c1)
4416
4417 \o results/ut-R.tmpout
4418 /*+
4419 Leading(bmt4 bmt3 bmt2 bmt1)
4420 Rows(bmt4 bmt3 *0.6)
4421 */
4422 EXPLAIN SELECT bmt1.c1 FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4423 LOG:  pg_hint_plan:
4424 used hint:
4425 Leading(bmt4 bmt3 bmt2 bmt1)
4426 Rows(bmt3 bmt4 *0.6)
4427 not used hint:
4428 duplication hint:
4429 error hint:
4430
4431 \o
4432 \! sql/maskout.sh results/ut-R.tmpout
4433                                        QUERY PLAN                                        
4434 -----------------------------------------------------------------------------------------
4435  Merge Join  (cost=xxx..xxx rows=60 width=xxx)
4436    Merge Cond: (bmt1.c1 = bmt2.c1)
4437    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4438    ->  Sort  (cost=xxx..xxx rows=60 width=xxx)
4439          Sort Key: bmt2.c1
4440          ->  Hash Join  (cost=xxx..xxx rows=60 width=xxx)
4441                Hash Cond: (bmt3.c1 = bmt2.c1)
4442                ->  Hash Join  (cost=xxx..xxx rows=678 width=xxx)
4443                      Hash Cond: (bmt3.c1 = bmt4.c1)
4444                      ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4445                      ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
4446                            ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
4447                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
4448                      ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4449
4450 -- No. R-2-5-3
4451 \o results/ut-R.tmpout
4452 EXPLAIN SELECT bmt1.c1 FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4453 \o
4454 \! sql/maskout.sh results/ut-R.tmpout
4455                                            QUERY PLAN                                           
4456 ------------------------------------------------------------------------------------------------
4457  Nested Loop  (cost=xxx..xxx rows=100 width=xxx)
4458    ->  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4459          Merge Cond: (bmt1.c1 = bmt2.c1)
4460          ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
4461                Merge Cond: (bmt1.c1 = bmt3.c1)
4462                ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4463                ->  Index Only Scan using t3_i1 on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4464          ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4465                Sort Key: bmt2.c1
4466                ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4467    ->  Index Only Scan using t4_i1 on t4 bmt4  (cost=xxx..xxx rows=1 width=xxx)
4468          Index Cond: (c1 = bmt1.c1)
4469
4470 \o results/ut-R.tmpout
4471 /*+
4472 Leading(bmt4 bmt3 bmt2 bmt1)
4473 Rows(bmt4 bmt1 *0.5)
4474 */
4475 EXPLAIN SELECT bmt1.c1 FROM s1.t1 bmt1, (SELECT ctid, * FROM s1.t2 bmt2) sbmt2, (SELECT ctid, * FROM s1.t3 bmt3) sbmt3, (SELECT ctid, * FROM s1.t4 bmt4) sbmt4 WHERE bmt1.c1 = sbmt2.c1 AND bmt1.c1 = sbmt3.c1 AND bmt1.c1 = sbmt4.c1;
4476 LOG:  pg_hint_plan:
4477 used hint:
4478 Leading(bmt4 bmt3 bmt2 bmt1)
4479 Rows(bmt1 bmt4 *0.5)
4480 not used hint:
4481 duplication hint:
4482 error hint:
4483
4484 \o
4485 \! sql/maskout.sh results/ut-R.tmpout
4486                                        QUERY PLAN                                        
4487 -----------------------------------------------------------------------------------------
4488  Merge Join  (cost=xxx..xxx rows=50 width=xxx)
4489    Merge Cond: (bmt1.c1 = bmt2.c1)
4490    ->  Index Only Scan using t1_i1 on t1 bmt1  (cost=xxx..xxx rows=1000 width=xxx)
4491    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4492          Sort Key: bmt2.c1
4493          ->  Hash Join  (cost=xxx..xxx rows=100 width=xxx)
4494                Hash Cond: (bmt3.c1 = bmt2.c1)
4495                ->  Hash Join  (cost=xxx..xxx rows=1130 width=xxx)
4496                      Hash Cond: (bmt3.c1 = bmt4.c1)
4497                      ->  Seq Scan on t3 bmt3  (cost=xxx..xxx rows=1130 width=xxx)
4498                      ->  Hash  (cost=xxx..xxx rows=1130 width=xxx)
4499                            ->  Seq Scan on t4 bmt4  (cost=xxx..xxx rows=1130 width=xxx)
4500                ->  Hash  (cost=xxx..xxx rows=100 width=xxx)
4501                      ->  Seq Scan on t2 bmt2  (cost=xxx..xxx rows=100 width=xxx)
4502
4503 ----
4504 ---- No. R-3-1 abusolute value
4505 ----
4506 -- No. R-3-1-1
4507 \o results/ut-R.tmpout
4508 /*+Rows(t1 t2 #0)*/
4509 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4510 WARNING:  Force estimate to be at least one row, to avoid possible divide-by-zero when interpolating costs : Rows(t1 t2 #0)
4511 LOG:  pg_hint_plan:
4512 used hint:
4513 Rows(t1 t2 #0)
4514 not used hint:
4515 duplication hint:
4516 error hint:
4517
4518 \o
4519 \! sql/maskout.sh results/ut-R.tmpout
4520                                 QUERY PLAN                                 
4521 ---------------------------------------------------------------------------
4522  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4523    Merge Cond: (t1.c1 = t2.c1)
4524    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4525    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4526          Sort Key: t2.c1
4527          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4528
4529 -- No. R-3-1-2
4530 \o results/ut-R.tmpout
4531 /*+Rows(t1 t2 #5)*/
4532 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4533 LOG:  pg_hint_plan:
4534 used hint:
4535 Rows(t1 t2 #5)
4536 not used hint:
4537 duplication hint:
4538 error hint:
4539
4540 \o
4541 \! sql/maskout.sh results/ut-R.tmpout
4542                                 QUERY PLAN                                 
4543 ---------------------------------------------------------------------------
4544  Merge Join  (cost=xxx..xxx rows=5 width=xxx)
4545    Merge Cond: (t1.c1 = t2.c1)
4546    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4547    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4548          Sort Key: t2.c1
4549          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4550
4551 ----
4552 ---- No. R-3-2 increase or decrease value
4553 ----
4554 -- No. R-3-2-1
4555 \o results/ut-R.tmpout
4556 /*+Rows(t1 t2 +1)*/
4557 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4558 LOG:  pg_hint_plan:
4559 used hint:
4560 Rows(t1 t2 +1)
4561 not used hint:
4562 duplication hint:
4563 error hint:
4564
4565 \o
4566 \! sql/maskout.sh results/ut-R.tmpout
4567                                 QUERY PLAN                                 
4568 ---------------------------------------------------------------------------
4569  Merge Join  (cost=xxx..xxx rows=101 width=xxx)
4570    Merge Cond: (t1.c1 = t2.c1)
4571    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4572    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4573          Sort Key: t2.c1
4574          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4575
4576 -- No. R-3-2-2
4577 \o results/ut-R.tmpout
4578 /*+Rows(t1 t2 -1)*/
4579 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4580 LOG:  pg_hint_plan:
4581 used hint:
4582 Rows(t1 t2 -1)
4583 not used hint:
4584 duplication hint:
4585 error hint:
4586
4587 \o
4588 \! sql/maskout.sh results/ut-R.tmpout
4589                                 QUERY PLAN                                 
4590 ---------------------------------------------------------------------------
4591  Merge Join  (cost=xxx..xxx rows=99 width=xxx)
4592    Merge Cond: (t1.c1 = t2.c1)
4593    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4594    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4595          Sort Key: t2.c1
4596          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4597
4598 -- No. R-3-2-3
4599 \o results/ut-R.tmpout
4600 /*+Rows(t1 t2 -1000)*/
4601 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4602 WARNING:  Force estimate to be at least one row, to avoid possible divide-by-zero when interpolating costs : Rows(t1 t2 -1000)
4603 LOG:  pg_hint_plan:
4604 used hint:
4605 Rows(t1 t2 -1000)
4606 not used hint:
4607 duplication hint:
4608 error hint:
4609
4610 \o
4611 \! sql/maskout.sh results/ut-R.tmpout
4612                                 QUERY PLAN                                 
4613 ---------------------------------------------------------------------------
4614  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4615    Merge Cond: (t1.c1 = t2.c1)
4616    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4617    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4618          Sort Key: t2.c1
4619          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4620
4621 ----
4622 ---- No. R-3-3 multiple 
4623 ----
4624 -- No. R-3-3-1
4625 \o results/ut-R.tmpout
4626 /*+Rows(t1 t2 *0)*/
4627 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4628 WARNING:  Force estimate to be at least one row, to avoid possible divide-by-zero when interpolating costs : Rows(t1 t2 *0)
4629 LOG:  pg_hint_plan:
4630 used hint:
4631 Rows(t1 t2 *0)
4632 not used hint:
4633 duplication hint:
4634 error hint:
4635
4636 \o
4637 \! sql/maskout.sh results/ut-R.tmpout
4638                                 QUERY PLAN                                 
4639 ---------------------------------------------------------------------------
4640  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4641    Merge Cond: (t1.c1 = t2.c1)
4642    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4643    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4644          Sort Key: t2.c1
4645          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4646
4647 -- No. R-3-3-2
4648 \o results/ut-R.tmpout
4649 /*+Rows(t1 t2 *2)*/
4650 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4651 LOG:  pg_hint_plan:
4652 used hint:
4653 Rows(t1 t2 *2)
4654 not used hint:
4655 duplication hint:
4656 error hint:
4657
4658 \o
4659 \! sql/maskout.sh results/ut-R.tmpout
4660                                 QUERY PLAN                                 
4661 ---------------------------------------------------------------------------
4662  Merge Join  (cost=xxx..xxx rows=200 width=xxx)
4663    Merge Cond: (t1.c1 = t2.c1)
4664    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4665    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4666          Sort Key: t2.c1
4667          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4668
4669 -- No. R-3-3-3
4670 \o results/ut-R.tmpout
4671 /*+Rows(t1 t2 *0.1)*/
4672 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4673 LOG:  pg_hint_plan:
4674 used hint:
4675 Rows(t1 t2 *0.1)
4676 not used hint:
4677 duplication hint:
4678 error hint:
4679
4680 \o
4681 \! sql/maskout.sh results/ut-R.tmpout
4682                                 QUERY PLAN                                 
4683 ---------------------------------------------------------------------------
4684  Merge Join  (cost=xxx..xxx rows=10 width=xxx)
4685    Merge Cond: (t1.c1 = t2.c1)
4686    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4687    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4688          Sort Key: t2.c1
4689          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4690
4691 ----
4692 ---- No. R-3-4 join inherit tables
4693 ----
4694 -- No. R-3-4-1
4695 \o results/ut-R.tmpout
4696 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
4697 \o
4698 \! sql/maskout.sh results/ut-R.tmpout
4699                                QUERY PLAN                                
4700 -------------------------------------------------------------------------
4701  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
4702    Hash Cond: (p2.c1 = p1.c1)
4703    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
4704          ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
4705          ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
4706          ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
4707          ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
4708          ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
4709          ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
4710          ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
4711          ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
4712          ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
4713          ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
4714    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
4715          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
4716                ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
4717                ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
4718                ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
4719                ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
4720
4721 \o results/ut-R.tmpout
4722 /*+Rows(p1 p2 #1)*/
4723 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
4724 LOG:  pg_hint_plan:
4725 used hint:
4726 Rows(p1 p2 #1)
4727 not used hint:
4728 duplication hint:
4729 error hint:
4730
4731 \o
4732 \! sql/maskout.sh results/ut-R.tmpout
4733                                QUERY PLAN                                
4734 -------------------------------------------------------------------------
4735  Hash Join  (cost=xxx..xxx rows=1 width=xxx)
4736    Hash Cond: (p2.c1 = p1.c1)
4737    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
4738          ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
4739          ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
4740          ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
4741          ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
4742          ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
4743          ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
4744          ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
4745          ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
4746          ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
4747          ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
4748    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
4749          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
4750                ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
4751                ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
4752                ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
4753                ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
4754
4755 -- No. R-3-4-2
4756 \o results/ut-R.tmpout
4757 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
4758 \o
4759 \! sql/maskout.sh results/ut-R.tmpout
4760                                QUERY PLAN                                
4761 -------------------------------------------------------------------------
4762  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
4763    Hash Cond: (p2.c1 = p1.c1)
4764    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
4765          ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
4766          ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
4767          ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
4768          ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
4769          ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
4770          ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
4771          ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
4772          ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
4773          ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
4774          ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
4775    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
4776          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
4777                ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
4778                ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
4779                ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
4780                ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
4781
4782 \o results/ut-R.tmpout
4783 /*+Rows(p1c1 p2c1 #1)*/
4784 EXPLAIN SELECT * FROM s1.p1, s1.p2 WHERE p1.c1 = p2.c1;
4785 LOG:  pg_hint_plan:
4786 used hint:
4787 not used hint:
4788 Rows(p1c1 p2c1 #1)
4789 duplication hint:
4790 error hint:
4791
4792 \o
4793 \! sql/maskout.sh results/ut-R.tmpout
4794                                QUERY PLAN                                
4795 -------------------------------------------------------------------------
4796  Hash Join  (cost=xxx..xxx rows=301 width=xxx)
4797    Hash Cond: (p2.c1 = p1.c1)
4798    ->  Append  (cost=xxx..xxx rows=304 width=xxx)
4799          ->  Seq Scan on p2  (cost=xxx..xxx rows=1 width=xxx)
4800          ->  Seq Scan on p2c1  (cost=xxx..xxx rows=1 width=xxx)
4801          ->  Seq Scan on p2c2  (cost=xxx..xxx rows=1 width=xxx)
4802          ->  Seq Scan on p2c3  (cost=xxx..xxx rows=1 width=xxx)
4803          ->  Seq Scan on p2c1c1  (cost=xxx..xxx rows=50 width=xxx)
4804          ->  Seq Scan on p2c1c2  (cost=xxx..xxx rows=50 width=xxx)
4805          ->  Seq Scan on p2c2c1  (cost=xxx..xxx rows=50 width=xxx)
4806          ->  Seq Scan on p2c2c2  (cost=xxx..xxx rows=50 width=xxx)
4807          ->  Seq Scan on p2c3c1  (cost=xxx..xxx rows=50 width=xxx)
4808          ->  Seq Scan on p2c3c2  (cost=xxx..xxx rows=50 width=xxx)
4809    ->  Hash  (cost=xxx..xxx rows=301 width=xxx)
4810          ->  Append  (cost=xxx..xxx rows=301 width=xxx)
4811                ->  Seq Scan on p1  (cost=xxx..xxx rows=1 width=xxx)
4812                ->  Seq Scan on p1c1  (cost=xxx..xxx rows=100 width=xxx)
4813                ->  Seq Scan on p1c2  (cost=xxx..xxx rows=100 width=xxx)
4814                ->  Seq Scan on p1c3  (cost=xxx..xxx rows=100 width=xxx)
4815
4816 ----
4817 ---- No. R-3-5 conflict join method hint
4818 ----
4819 -- No. R-3-5-1
4820 \o results/ut-R.tmpout
4821 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4822 \o
4823 \! sql/maskout.sh results/ut-R.tmpout
4824                                 QUERY PLAN                                 
4825 ---------------------------------------------------------------------------
4826  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4827    Merge Cond: (t1.c1 = t2.c1)
4828    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4829    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4830          Sort Key: t2.c1
4831          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4832
4833 \o results/ut-R.tmpout
4834 /*+Rows(t1 t2 #1)Rows(t1 t2 #1)*/
4835 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4836 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t2 #1)Rows(t1 t2 #1)"
4837 DETAIL:  Conflict rows hint.
4838 LOG:  pg_hint_plan:
4839 used hint:
4840 Rows(t1 t2 #1)
4841 not used hint:
4842 duplication hint:
4843 Rows(t1 t2 #1)
4844 error hint:
4845
4846 \o
4847 \! sql/maskout.sh results/ut-R.tmpout
4848                                 QUERY PLAN                                 
4849 ---------------------------------------------------------------------------
4850  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4851    Merge Cond: (t1.c1 = t2.c1)
4852    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4853    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4854          Sort Key: t2.c1
4855          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4856
4857 -- No. R-3-5-2
4858 \o results/ut-R.tmpout
4859 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4860 \o
4861 \! sql/maskout.sh results/ut-R.tmpout
4862                                 QUERY PLAN                                 
4863 ---------------------------------------------------------------------------
4864  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4865    Merge Cond: (t1.c1 = t2.c1)
4866    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4867    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4868          Sort Key: t2.c1
4869          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4870
4871 \o results/ut-R.tmpout
4872 /*+Rows(t1 t2 #1)Rows(t1 t2 #1)Rows(t1 t2 #1)*/
4873 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4874 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t2 #1)Rows(t1 t2 #1)Rows(t1 t2 #1)"
4875 DETAIL:  Conflict rows hint.
4876 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t2 #1)Rows(t1 t2 #1)"
4877 DETAIL:  Conflict rows hint.
4878 LOG:  pg_hint_plan:
4879 used hint:
4880 Rows(t1 t2 #1)
4881 not used hint:
4882 duplication hint:
4883 Rows(t1 t2 #1)
4884 Rows(t1 t2 #1)
4885 error hint:
4886
4887 \o
4888 \! sql/maskout.sh results/ut-R.tmpout
4889                                 QUERY PLAN                                 
4890 ---------------------------------------------------------------------------
4891  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4892    Merge Cond: (t1.c1 = t2.c1)
4893    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4894    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4895          Sort Key: t2.c1
4896          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4897
4898 -- No. R-3-5-3
4899 \o results/ut-R.tmpout
4900 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4901 \o
4902 \! sql/maskout.sh results/ut-R.tmpout
4903                                 QUERY PLAN                                 
4904 ---------------------------------------------------------------------------
4905  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4906    Merge Cond: (t1.c1 = t2.c1)
4907    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4908    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4909          Sort Key: t2.c1
4910          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4911
4912 \o results/ut-R.tmpout
4913 /*+Rows(t1 t2 #1)Rows(t2 t1 #1)*/
4914 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4915 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t2 #1)Rows(t2 t1 #1)"
4916 DETAIL:  Conflict rows hint.
4917 LOG:  pg_hint_plan:
4918 used hint:
4919 Rows(t1 t2 #1)
4920 not used hint:
4921 duplication hint:
4922 Rows(t1 t2 #1)
4923 error hint:
4924
4925 \o
4926 \! sql/maskout.sh results/ut-R.tmpout
4927                                 QUERY PLAN                                 
4928 ---------------------------------------------------------------------------
4929  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4930    Merge Cond: (t1.c1 = t2.c1)
4931    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4932    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4933          Sort Key: t2.c1
4934          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4935
4936 -- No. R-3-5-4
4937 \o results/ut-R.tmpout
4938 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4939 \o
4940 \! sql/maskout.sh results/ut-R.tmpout
4941                                 QUERY PLAN                                 
4942 ---------------------------------------------------------------------------
4943  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4944    Merge Cond: (t1.c1 = t2.c1)
4945    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4946    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4947          Sort Key: t2.c1
4948          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4949
4950 \o results/ut-R.tmpout
4951 /*+Rows(t2 t1 #1)Rows(t1 t2 #1)Rows(t2 t1 #1)*/
4952 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4953 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t2 t1 #1)Rows(t1 t2 #1)Rows(t2 t1 #1)"
4954 DETAIL:  Conflict rows hint.
4955 INFO:  pg_hint_plan: hint syntax error at or near "Rows(t1 t2 #1)Rows(t2 t1 #1)"
4956 DETAIL:  Conflict rows hint.
4957 LOG:  pg_hint_plan:
4958 used hint:
4959 Rows(t1 t2 #1)
4960 not used hint:
4961 duplication hint:
4962 Rows(t1 t2 #1)
4963 Rows(t1 t2 #1)
4964 error hint:
4965
4966 \o
4967 \! sql/maskout.sh results/ut-R.tmpout
4968                                 QUERY PLAN                                 
4969 ---------------------------------------------------------------------------
4970  Merge Join  (cost=xxx..xxx rows=1 width=xxx)
4971    Merge Cond: (t1.c1 = t2.c1)
4972    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4973    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4974          Sort Key: t2.c1
4975          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4976
4977 ----
4978 ---- No. R-3-6 hint state output
4979 ----
4980 -- No. R-3-6-1
4981 SET client_min_messages TO DEBUG1;
4982 \o results/ut-R.tmpout
4983 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4984 \o
4985 \! sql/maskout.sh results/ut-R.tmpout
4986                                 QUERY PLAN                                 
4987 ---------------------------------------------------------------------------
4988  Merge Join  (cost=xxx..xxx rows=100 width=xxx)
4989    Merge Cond: (t1.c1 = t2.c1)
4990    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
4991    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
4992          Sort Key: t2.c1
4993          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
4994
4995 \o results/ut-R.tmpout
4996 /*+Rows(t1 t2 +1)*/
4997 EXPLAIN SELECT * FROM s1.t1, s1.t2 WHERE t1.c1 = t2.c1;
4998 DEBUG:  adjusted rows 100 to 101
4999 LOG:  pg_hint_plan:
5000 used hint:
5001 Rows(t1 t2 +1)
5002 not used hint:
5003 duplication hint:
5004 error hint:
5005
5006 \o
5007 \! sql/maskout.sh results/ut-R.tmpout
5008                                 QUERY PLAN                                 
5009 ---------------------------------------------------------------------------
5010  Merge Join  (cost=xxx..xxx rows=101 width=xxx)
5011    Merge Cond: (t1.c1 = t2.c1)
5012    ->  Index Scan using t1_i1 on t1  (cost=xxx..xxx rows=1000 width=xxx)
5013    ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
5014          Sort Key: t2.c1
5015          ->  Seq Scan on t2  (cost=xxx..xxx rows=100 width=xxx)
5016
5017 \! rm results/ut-R.tmpout