OSDN Git Service

3227d33961b45e48c5a41f64c532b93c53235904
[pghintplan/pg_hint_plan.git] / expected / pg_hint_plan.out
1 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
2                                   QUERY PLAN                                  
3 ------------------------------------------------------------------------------
4  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
5    Merge Cond: (t1.id = t2.id)
6    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
7    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
8 (4 rows)
9
10 EXPLAIN SELECT * FROM t1, t2 WHERE t1.val = t2.val;
11                                     QUERY PLAN                                     
12 -----------------------------------------------------------------------------------
13  Merge Join  (cost=0.00..1377.64 rows=100000 width=16)
14    Merge Cond: (t2.val = t1.val)
15    ->  Index Scan using t2_val on t2  (cost=0.00..55.12 rows=1000 width=8)
16    ->  Materialize  (cost=0.00..475.21 rows=10000 width=8)
17          ->  Index Scan using t1_val on t1  (cost=0.00..450.21 rows=10000 width=8)
18 (5 rows)
19
20 LOAD 'pg_hint_plan';
21 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
22                                   QUERY PLAN                                  
23 ------------------------------------------------------------------------------
24  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
25    Merge Cond: (t1.id = t2.id)
26    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
27    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
28 (4 rows)
29
30 EXPLAIN SELECT * FROM t1, t2 WHERE t1.val = t2.val;
31                                     QUERY PLAN                                     
32 -----------------------------------------------------------------------------------
33  Merge Join  (cost=0.00..1377.64 rows=100000 width=16)
34    Merge Cond: (t2.val = t1.val)
35    ->  Index Scan using t2_val on t2  (cost=0.00..55.12 rows=1000 width=8)
36    ->  Materialize  (cost=0.00..475.21 rows=10000 width=8)
37          ->  Index Scan using t1_val on t1  (cost=0.00..450.21 rows=10000 width=8)
38 (5 rows)
39
40 /* Test (t1 t2) */
41 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
42 INFO:  hint syntax error at or near "Test (t1 t2) "
43 DETAIL:  Keyword "Test" does not exist.
44                                   QUERY PLAN                                  
45 ------------------------------------------------------------------------------
46  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
47    Merge Cond: (t1.id = t2.id)
48    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
49    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
50 (4 rows)
51
52 SET pg_hint_plan.enable TO off;
53 /* Test (t1 t2) */
54 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
55                                   QUERY PLAN                                  
56 ------------------------------------------------------------------------------
57  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
58    Merge Cond: (t1.id = t2.id)
59    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
60    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
61 (4 rows)
62
63 SET pg_hint_plan.enable TO on;
64 /*Set(enable_indexscan off)*/
65 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
66                             QUERY PLAN                            
67 ------------------------------------------------------------------
68  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
69    Hash Cond: (t1.id = t2.id)
70    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
71    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
72          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
73 (5 rows)
74
75 /* Set(enable_indexscan off) Set(enable_hashjoin off) */
76 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
77                              QUERY PLAN                             
78 --------------------------------------------------------------------
79  Merge Join  (cost=874.21..894.21 rows=1000 width=16)
80    Merge Cond: (t1.id = t2.id)
81    ->  Sort  (cost=809.39..834.39 rows=10000 width=8)
82          Sort Key: t1.id
83          ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
84    ->  Sort  (cost=64.83..67.33 rows=1000 width=8)
85          Sort Key: t2.id
86          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
87 (8 rows)
88
89 /*       Set     (       enable_indexscan        off     )       */
90 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
91                             QUERY PLAN                            
92 ------------------------------------------------------------------
93  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
94    Hash Cond: (t1.id = t2.id)
95    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
96    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
97          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
98 (5 rows)
99
100 /*       
101                 Set      
102                 (        
103                 enable_indexscan         
104                 off      
105                 )        
106                 */              
107 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
108                             QUERY PLAN                            
109 ------------------------------------------------------------------
110  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
111    Hash Cond: (t1.id = t2.id)
112    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
113    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
114          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
115 (5 rows)
116
117 /* Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off)           
118                 Set(enable_seqscan off)
119                 */
120 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
121                                              QUERY PLAN                                              
122 -----------------------------------------------------------------------------------------------------
123  Hash Join  (cost=20000000055.75..20000000421.51 rows=1000 width=16)
124    Hash Cond: (t1.id = t2.id)
125    ->  Index Scan using t1_pkey on t1  (cost=10000000000.00..10000000318.26 rows=10000 width=8)
126    ->  Hash  (cost=10000000043.25..10000000043.25 rows=1000 width=8)
127          ->  Index Scan using t2_pkey on t2  (cost=10000000000.00..10000000043.25 rows=1000 width=8)
128 (5 rows)
129
130 /*Set(work_mem "1M")*/
131 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
132 INFO:  invalid value for parameter "work_mem": "1M"
133 HINT:  Valid units for this parameter are "kB", "MB", and "GB".
134                                   QUERY PLAN                                  
135 ------------------------------------------------------------------------------
136  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
137    Merge Cond: (t1.id = t2.id)
138    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
139    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
140 (4 rows)
141
142 /*Set(work_mem "1MB")*/
143 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
144                                   QUERY PLAN                                  
145 ------------------------------------------------------------------------------
146  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
147    Merge Cond: (t1.id = t2.id)
148    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
149    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
150 (4 rows)
151
152 /*Set(work_mem TO "1MB")*/
153 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
154 INFO:  hint syntax error at or near ""1MB")"
155 DETAIL:  Closed parenthesis is necessary.
156                                   QUERY PLAN                                  
157 ------------------------------------------------------------------------------
158  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
159    Merge Cond: (t1.id = t2.id)
160    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
161    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
162 (4 rows)
163
164 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
165                                   QUERY PLAN                                  
166 ------------------------------------------------------------------------------
167  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
168    Merge Cond: (t1.id = t2.id)
169    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
170    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
171 (4 rows)
172
173 /*SeqScan(t1 t2)*/
174 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
175 INFO:  hint syntax error at or near "t2)"
176 DETAIL:  Closed parenthesis is necessary.
177                                   QUERY PLAN                                  
178 ------------------------------------------------------------------------------
179  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
180    Merge Cond: (t1.id = t2.id)
181    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
182    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
183 (4 rows)
184
185 /*SeqScan(t1)*/
186 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
187                             QUERY PLAN                            
188 ------------------------------------------------------------------
189  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
190    Hash Cond: (t1.id = t2.id)
191    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
192    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
193          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
194 (5 rows)
195
196 /*SeqScan(t1)IndexScan(t2)*/
197 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
198                                     QUERY PLAN                                    
199 ----------------------------------------------------------------------------------
200  Hash Join  (cost=55.75..248.25 rows=1000 width=16)
201    Hash Cond: (t1.id = t2.id)
202    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
203    ->  Hash  (cost=43.25..43.25 rows=1000 width=8)
204          ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
205 (5 rows)
206
207 /*BitmapScan(t2)*/
208 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
209                                  QUERY PLAN                                 
210 ----------------------------------------------------------------------------
211  Nested Loop  (cost=0.26..42987.50 rows=1000 width=16)
212    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
213    ->  Bitmap Heap Scan on t2  (cost=0.26..4.27 rows=1 width=8)
214          Recheck Cond: (id = t1.id)
215          ->  Bitmap Index Scan on t2_pkey  (cost=0.00..0.26 rows=1 width=0)
216                Index Cond: (id = t1.id)
217 (6 rows)
218
219 /*BitmapScan(t2)NoSeqScan(t1)*/
220 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
221                                   QUERY PLAN                                  
222 ------------------------------------------------------------------------------
223  Nested Loop  (cost=0.26..43160.76 rows=1000 width=16)
224    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
225    ->  Bitmap Heap Scan on t2  (cost=0.26..4.27 rows=1 width=8)
226          Recheck Cond: (id = t1.id)
227          ->  Bitmap Index Scan on t2_pkey  (cost=0.00..0.26 rows=1 width=0)
228                Index Cond: (id = t1.id)
229 (6 rows)
230
231 /*NoIndexScan(t1)*/
232 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
233                             QUERY PLAN                            
234 ------------------------------------------------------------------
235  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
236    Hash Cond: (t1.id = t2.id)
237    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
238    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
239          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
240 (5 rows)
241
242 EXPLAIN SELECT * FROM t1, t4 WHERE t1.val < 10;
243                                   QUERY PLAN                                   
244 -------------------------------------------------------------------------------
245  Nested Loop  (cost=20.01..203.64 rows=10000 width=16)
246    ->  Bitmap Heap Scan on t1  (cost=20.01..77.51 rows=1000 width=8)
247          Recheck Cond: (val < 10)
248          ->  Bitmap Index Scan on t1_val  (cost=0.00..19.76 rows=1000 width=0)
249                Index Cond: (val < 10)
250    ->  Materialize  (cost=0.00..1.15 rows=10 width=8)
251          ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
252 (7 rows)
253
254 /*NoBitmapScan(t1)*/
255 EXPLAIN SELECT * FROM t1, t4 WHERE t1.val < 10;
256                           QUERY PLAN                           
257 ---------------------------------------------------------------
258  Nested Loop  (cost=0.00..296.12 rows=10000 width=16)
259    ->  Seq Scan on t1  (cost=0.00..170.00 rows=1000 width=8)
260          Filter: (val < 10)
261    ->  Materialize  (cost=0.00..1.15 rows=10 width=8)
262          ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
263 (5 rows)
264
265 EXPLAIN SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)';
266                                 QUERY PLAN                                 
267 ---------------------------------------------------------------------------
268  Merge Join  (cost=1.14..2.41 rows=1 width=16)
269    Merge Cond: (t3.id = t4.id)
270    ->  Index Scan using t3_pkey on t3  (cost=0.00..13.75 rows=100 width=8)
271    ->  Sort  (cost=1.14..1.14 rows=1 width=8)
272          Sort Key: t4.id
273          ->  Seq Scan on t4  (cost=0.00..1.12 rows=1 width=8)
274                Filter: (ctid = '(1,1)'::tid)
275 (7 rows)
276
277 /*TidScan(t4)*/
278 EXPLAIN SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)';
279                                 QUERY PLAN                                 
280 ---------------------------------------------------------------------------
281  Merge Join  (cost=4.02..5.30 rows=1 width=16)
282    Merge Cond: (t3.id = t4.id)
283    ->  Index Scan using t3_pkey on t3  (cost=0.00..13.75 rows=100 width=8)
284    ->  Sort  (cost=4.02..4.03 rows=1 width=8)
285          Sort Key: t4.id
286          ->  Tid Scan on t4  (cost=0.00..4.01 rows=1 width=8)
287                TID Cond: (ctid = '(1,1)'::tid)
288 (7 rows)
289
290 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)';
291                                QUERY PLAN                               
292 ------------------------------------------------------------------------
293  Nested Loop  (cost=0.00..12.29 rows=1 width=16)
294    ->  Tid Scan on t1  (cost=0.00..4.01 rows=1 width=8)
295          TID Cond: (ctid = '(1,1)'::tid)
296    ->  Index Scan using t2_pkey on t2  (cost=0.00..8.27 rows=1 width=8)
297          Index Cond: (id = t1.id)
298 (5 rows)
299
300 /*NoTidScan(t1)*/
301 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)';
302                                QUERY PLAN                               
303 ------------------------------------------------------------------------
304  Nested Loop  (cost=0.00..178.28 rows=1 width=16)
305    ->  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
306          Filter: (ctid = '(1,1)'::tid)
307    ->  Index Scan using t2_pkey on t2  (cost=0.00..8.27 rows=1 width=8)
308          Index Cond: (id = t1.id)
309 (5 rows)
310
311 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
312                                   QUERY PLAN                                  
313 ------------------------------------------------------------------------------
314  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
315    Merge Cond: (t1.id = t2.id)
316    ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
317    ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
318 (4 rows)
319
320 /*HashJoin(t1 t2)*/
321 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
322                             QUERY PLAN                            
323 ------------------------------------------------------------------
324  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
325    Hash Cond: (t1.id = t2.id)
326    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
327    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
328          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
329 (5 rows)
330
331 /*NestLoop(t1 t2)*/
332 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
333                                QUERY PLAN                               
334 ------------------------------------------------------------------------
335  Nested Loop  (cost=0.00..607.00 rows=1000 width=16)
336    ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
337    ->  Index Scan using t1_pkey on t1  (cost=0.00..0.58 rows=1 width=8)
338          Index Cond: (id = t2.id)
339 (4 rows)
340
341 /*NoMergeJoin(t1 t2)*/
342 EXPLAIN SELECT * FROM t1, t2 WHERE t1.id = t2.id;
343                             QUERY PLAN                            
344 ------------------------------------------------------------------
345  Hash Join  (cost=27.50..220.00 rows=1000 width=16)
346    Hash Cond: (t1.id = t2.id)
347    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
348    ->  Hash  (cost=15.00..15.00 rows=1000 width=8)
349          ->  Seq Scan on t2  (cost=0.00..15.00 rows=1000 width=8)
350 (5 rows)
351
352 EXPLAIN SELECT * FROM t1, t3 WHERE t1.val = t3.val;
353                            QUERY PLAN                           
354 ----------------------------------------------------------------
355  Hash Join  (cost=3.25..285.75 rows=10000 width=16)
356    Hash Cond: (t1.val = t3.val)
357    ->  Seq Scan on t1  (cost=0.00..145.00 rows=10000 width=8)
358    ->  Hash  (cost=2.00..2.00 rows=100 width=8)
359          ->  Seq Scan on t3  (cost=0.00..2.00 rows=100 width=8)
360 (5 rows)
361
362 /*MergeJoin(t1 t3)*/
363 EXPLAIN SELECT * FROM t1, t3 WHERE t1.val = t3.val;
364                                  QUERY PLAN                                  
365 -----------------------------------------------------------------------------
366  Merge Join  (cost=10.07..630.03 rows=10000 width=16)
367    Merge Cond: (t1.val = t3.val)
368    ->  Index Scan using t1_val on t1  (cost=0.00..450.21 rows=10000 width=8)
369    ->  Sort  (cost=5.32..5.57 rows=100 width=8)
370          Sort Key: t3.val
371          ->  Seq Scan on t3  (cost=0.00..2.00 rows=100 width=8)
372 (6 rows)
373
374 /*NestLoop(t1 t3)*/
375 EXPLAIN SELECT * FROM t1, t3 WHERE t1.val = t3.val;
376                                QUERY PLAN                                
377 -------------------------------------------------------------------------
378  Nested Loop  (cost=0.00..628.20 rows=10000 width=16)
379    ->  Seq Scan on t3  (cost=0.00..2.00 rows=100 width=8)
380    ->  Index Scan using t1_val on t1  (cost=0.00..5.01 rows=100 width=8)
381          Index Cond: (val = t3.val)
382 (4 rows)
383
384 /*NoHashJoin(t1 t3)*/
385 EXPLAIN SELECT * FROM t1, t3 WHERE t1.val = t3.val;
386                                QUERY PLAN                                
387 -------------------------------------------------------------------------
388  Nested Loop  (cost=0.00..628.20 rows=10000 width=16)
389    ->  Seq Scan on t3  (cost=0.00..2.00 rows=100 width=8)
390    ->  Index Scan using t1_val on t1  (cost=0.00..5.01 rows=100 width=8)
391          Index Cond: (val = t3.val)
392 (4 rows)
393
394 EXPLAIN SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
395                                         QUERY PLAN                                        
396 ------------------------------------------------------------------------------------------
397  Nested Loop  (cost=1.27..1.70 rows=1 width=32)
398    ->  Merge Join  (cost=1.27..1.42 rows=1 width=24)
399          Merge Cond: (t1.id = t4.id)
400          ->  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
401                Merge Cond: (t1.id = t2.id)
402                ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
403                ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
404          ->  Sort  (cost=1.27..1.29 rows=10 width=8)
405                Sort Key: t4.id
406                ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
407    ->  Index Scan using t3_pkey on t3  (cost=0.00..0.27 rows=1 width=8)
408          Index Cond: (id = t1.id)
409 (12 rows)
410
411 /*MergeJoin(t4 t1 t2 t3)*/
412 EXPLAIN SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
413                                         QUERY PLAN                                        
414 ------------------------------------------------------------------------------------------
415  Merge Join  (cost=1.27..2.83 rows=1 width=32)
416    Merge Cond: (t1.id = t4.id)
417    ->  Merge Join  (cost=0.00..15.03 rows=10 width=24)
418          Merge Cond: (t1.id = t3.id)
419          ->  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
420                Merge Cond: (t1.id = t2.id)
421                ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
422                ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
423          ->  Index Scan using t3_pkey on t3  (cost=0.00..13.75 rows=100 width=8)
424    ->  Sort  (cost=1.27..1.29 rows=10 width=8)
425          Sort Key: t4.id
426          ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
427 (12 rows)
428
429 /*HashJoin(t3 t4 t1 t2)*/
430 EXPLAIN SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
431                                            QUERY PLAN                                           
432 ------------------------------------------------------------------------------------------------
433  Hash Join  (cost=1.43..3.82 rows=1 width=32)
434    Hash Cond: (t3.id = t1.id)
435    ->  Seq Scan on t3  (cost=0.00..2.00 rows=100 width=8)
436    ->  Hash  (cost=1.42..1.42 rows=1 width=24)
437          ->  Merge Join  (cost=1.27..1.42 rows=1 width=24)
438                Merge Cond: (t1.id = t4.id)
439                ->  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
440                      Merge Cond: (t1.id = t2.id)
441                      ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
442                      ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
443                ->  Sort  (cost=1.27..1.29 rows=10 width=8)
444                      Sort Key: t4.id
445                      ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
446 (13 rows)
447
448 /*NoNestLoop(t4 t1 t3 t2)*/
449 EXPLAIN SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
450                                         QUERY PLAN                                        
451 ------------------------------------------------------------------------------------------
452  Merge Join  (cost=1.27..2.83 rows=1 width=32)
453    Merge Cond: (t1.id = t4.id)
454    ->  Merge Join  (cost=0.00..15.03 rows=10 width=24)
455          Merge Cond: (t1.id = t3.id)
456          ->  Merge Join  (cost=0.00..90.08 rows=1000 width=16)
457                Merge Cond: (t1.id = t2.id)
458                ->  Index Scan using t1_pkey on t1  (cost=0.00..318.26 rows=10000 width=8)
459                ->  Index Scan using t2_pkey on t2  (cost=0.00..43.25 rows=1000 width=8)
460          ->  Index Scan using t3_pkey on t3  (cost=0.00..13.75 rows=100 width=8)
461    ->  Sort  (cost=1.27..1.29 rows=10 width=8)
462          Sort Key: t4.id
463          ->  Seq Scan on t4  (cost=0.00..1.10 rows=10 width=8)
464 (12 rows)
465
466 \q