OSDN Git Service

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