OSDN Git Service

ヒント保存のスタックについてコメントを追加し、余分なものを削除した。
[pghintplan/pg_hint_plan.git] / expected / prepare-9.2.out
1 LOAD 'pg_hint_plan';
2 SET search_path TO public;
3 SET pg_hint_plan.enable TO on;
4 SET pg_hint_plan.debug_print TO on;
5 SET client_min_messages TO LOG;
6 EXPLAIN (COSTS false) SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id;
7                    QUERY PLAN                    
8 -------------------------------------------------
9  Aggregate
10    ->  Merge Join
11          Merge Cond: (t1.id = t2.id)
12          ->  Index Only Scan using t1_pkey on t1
13          ->  Index Only Scan using t2_pkey on t2
14 (5 rows)
15
16 EXPLAIN (COSTS false) SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > 10;
17                    QUERY PLAN                    
18 -------------------------------------------------
19  Aggregate
20    ->  Merge Join
21          Merge Cond: (t1.id = t2.id)
22          ->  Index Only Scan using t1_pkey on t1
23                Index Cond: (id > 10)
24          ->  Index Only Scan using t2_pkey on t2
25 (6 rows)
26
27 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
28 -- 9.2:PREPAREでヒント句を指定しても、実行計画は制御できない
29 /*+ NestLoop(t1 t2) */
30 PREPARE p1 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id;
31 EXPLAIN (COSTS false) EXECUTE p1;
32                    QUERY PLAN                    
33 -------------------------------------------------
34  Aggregate
35    ->  Merge Join
36          Merge Cond: (t1.id = t2.id)
37          ->  Index Only Scan using t1_pkey on t1
38          ->  Index Only Scan using t2_pkey on t2
39 (5 rows)
40
41 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
42 -- 9.2:パラメータがない場合は、1回目のEXPLAINで実行計画が決定する
43 /*+ NestLoop(t1 t2) */
44 PREPARE p2 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id;
45 /*+ HashJoin(t1 t2) */
46 EXPLAIN (COSTS false) EXECUTE p2;
47 LOG:  pg_hint_plan:
48 used hint:
49 HashJoin(t1 t2)
50 not used hint:
51 duplication hint:
52 error hint:
53
54              QUERY PLAN             
55 ------------------------------------
56  Aggregate
57    ->  Hash Join
58          Hash Cond: (t1.id = t2.id)
59          ->  Seq Scan on t1
60          ->  Hash
61                ->  Seq Scan on t2
62 (6 rows)
63
64 EXPLAIN (COSTS false) EXECUTE p2;
65              QUERY PLAN             
66 ------------------------------------
67  Aggregate
68    ->  Hash Join
69          Hash Cond: (t1.id = t2.id)
70          ->  Seq Scan on t1
71          ->  Hash
72                ->  Seq Scan on t2
73 (6 rows)
74
75 EXPLAIN (COSTS false) EXECUTE p2;
76              QUERY PLAN             
77 ------------------------------------
78  Aggregate
79    ->  Hash Join
80          Hash Cond: (t1.id = t2.id)
81          ->  Seq Scan on t1
82          ->  Hash
83                ->  Seq Scan on t2
84 (6 rows)
85
86 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
87 -- 9.2:5回目のEXPLAINまでヒント句を指定しても、6回目以降は本来の実行計画に戻る
88 /*+ NestLoop(t1 t2) */
89 PREPARE p3 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > $1;
90 /*+ HashJoin(t1 t2) */
91 EXPLAIN (COSTS false) EXECUTE p3 (10);
92 LOG:  pg_hint_plan:
93 used hint:
94 HashJoin(t1 t2)
95 not used hint:
96 duplication hint:
97 error hint:
98
99              QUERY PLAN             
100 ------------------------------------
101  Aggregate
102    ->  Hash Join
103          Hash Cond: (t1.id = t2.id)
104          ->  Seq Scan on t1
105                Filter: (id > 10)
106          ->  Hash
107                ->  Seq Scan on t2
108 (7 rows)
109
110 /*+ HashJoin(t1 t2) */
111 EXPLAIN (COSTS false) EXECUTE p3 (10);
112 LOG:  pg_hint_plan:
113 used hint:
114 HashJoin(t1 t2)
115 not used hint:
116 duplication hint:
117 error hint:
118
119              QUERY PLAN             
120 ------------------------------------
121  Aggregate
122    ->  Hash Join
123          Hash Cond: (t1.id = t2.id)
124          ->  Seq Scan on t1
125                Filter: (id > 10)
126          ->  Hash
127                ->  Seq Scan on t2
128 (7 rows)
129
130 /*+ HashJoin(t1 t2) */
131 EXPLAIN (COSTS false) EXECUTE p3 (10);
132 LOG:  pg_hint_plan:
133 used hint:
134 HashJoin(t1 t2)
135 not used hint:
136 duplication hint:
137 error hint:
138
139              QUERY PLAN             
140 ------------------------------------
141  Aggregate
142    ->  Hash Join
143          Hash Cond: (t1.id = t2.id)
144          ->  Seq Scan on t1
145                Filter: (id > 10)
146          ->  Hash
147                ->  Seq Scan on t2
148 (7 rows)
149
150 /*+ HashJoin(t1 t2) */
151 EXPLAIN (COSTS false) EXECUTE p3 (10);
152 LOG:  pg_hint_plan:
153 used hint:
154 HashJoin(t1 t2)
155 not used hint:
156 duplication hint:
157 error hint:
158
159              QUERY PLAN             
160 ------------------------------------
161  Aggregate
162    ->  Hash Join
163          Hash Cond: (t1.id = t2.id)
164          ->  Seq Scan on t1
165                Filter: (id > 10)
166          ->  Hash
167                ->  Seq Scan on t2
168 (7 rows)
169
170 /*+ HashJoin(t1 t2) */
171 EXPLAIN (COSTS false) EXECUTE p3 (10);
172 LOG:  pg_hint_plan:
173 used hint:
174 HashJoin(t1 t2)
175 not used hint:
176 duplication hint:
177 error hint:
178
179              QUERY PLAN             
180 ------------------------------------
181  Aggregate
182    ->  Hash Join
183          Hash Cond: (t1.id = t2.id)
184          ->  Seq Scan on t1
185                Filter: (id > 10)
186          ->  Hash
187                ->  Seq Scan on t2
188 (7 rows)
189
190 EXPLAIN (COSTS false) EXECUTE p3 (10);
191                    QUERY PLAN                    
192 -------------------------------------------------
193  Aggregate
194    ->  Merge Join
195          Merge Cond: (t1.id = t2.id)
196          ->  Index Only Scan using t1_pkey on t1
197                Index Cond: (id > $1)
198          ->  Index Only Scan using t2_pkey on t2
199 (6 rows)
200
201 EXPLAIN (COSTS false) EXECUTE p3 (10);
202                    QUERY PLAN                    
203 -------------------------------------------------
204  Aggregate
205    ->  Merge Join
206          Merge Cond: (t1.id = t2.id)
207          ->  Index Only Scan using t1_pkey on t1
208                Index Cond: (id > $1)
209          ->  Index Only Scan using t2_pkey on t2
210 (6 rows)
211
212 EXPLAIN (COSTS false) EXECUTE p3 (10);
213                    QUERY PLAN                    
214 -------------------------------------------------
215  Aggregate
216    ->  Merge Join
217          Merge Cond: (t1.id = t2.id)
218          ->  Index Only Scan using t1_pkey on t1
219                Index Cond: (id > $1)
220          ->  Index Only Scan using t2_pkey on t2
221 (6 rows)
222
223 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
224 -- 9.2:6回目のEXPLAINまでヒント句を指定すると、7回目以降も実行計画が固定される
225 /*+ NestLoop(t1 t2) */
226 PREPARE p4 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > $1;
227 /*+ HashJoin(t1 t2) */
228 EXPLAIN (COSTS false) EXECUTE p4 (10);
229 LOG:  pg_hint_plan:
230 used hint:
231 HashJoin(t1 t2)
232 not used hint:
233 duplication hint:
234 error hint:
235
236              QUERY PLAN             
237 ------------------------------------
238  Aggregate
239    ->  Hash Join
240          Hash Cond: (t1.id = t2.id)
241          ->  Seq Scan on t1
242                Filter: (id > 10)
243          ->  Hash
244                ->  Seq Scan on t2
245 (7 rows)
246
247 /*+ HashJoin(t1 t2) */
248 EXPLAIN (COSTS false) EXECUTE p4 (10);
249 LOG:  pg_hint_plan:
250 used hint:
251 HashJoin(t1 t2)
252 not used hint:
253 duplication hint:
254 error hint:
255
256              QUERY PLAN             
257 ------------------------------------
258  Aggregate
259    ->  Hash Join
260          Hash Cond: (t1.id = t2.id)
261          ->  Seq Scan on t1
262                Filter: (id > 10)
263          ->  Hash
264                ->  Seq Scan on t2
265 (7 rows)
266
267 /*+ HashJoin(t1 t2) */
268 EXPLAIN (COSTS false) EXECUTE p4 (10);
269 LOG:  pg_hint_plan:
270 used hint:
271 HashJoin(t1 t2)
272 not used hint:
273 duplication hint:
274 error hint:
275
276              QUERY PLAN             
277 ------------------------------------
278  Aggregate
279    ->  Hash Join
280          Hash Cond: (t1.id = t2.id)
281          ->  Seq Scan on t1
282                Filter: (id > 10)
283          ->  Hash
284                ->  Seq Scan on t2
285 (7 rows)
286
287 /*+ HashJoin(t1 t2) */
288 EXPLAIN (COSTS false) EXECUTE p4 (10);
289 LOG:  pg_hint_plan:
290 used hint:
291 HashJoin(t1 t2)
292 not used hint:
293 duplication hint:
294 error hint:
295
296              QUERY PLAN             
297 ------------------------------------
298  Aggregate
299    ->  Hash Join
300          Hash Cond: (t1.id = t2.id)
301          ->  Seq Scan on t1
302                Filter: (id > 10)
303          ->  Hash
304                ->  Seq Scan on t2
305 (7 rows)
306
307 /*+ HashJoin(t1 t2) */
308 EXPLAIN (COSTS false) EXECUTE p4 (10);
309 LOG:  pg_hint_plan:
310 used hint:
311 HashJoin(t1 t2)
312 not used hint:
313 duplication hint:
314 error hint:
315
316              QUERY PLAN             
317 ------------------------------------
318  Aggregate
319    ->  Hash Join
320          Hash Cond: (t1.id = t2.id)
321          ->  Seq Scan on t1
322                Filter: (id > 10)
323          ->  Hash
324                ->  Seq Scan on t2
325 (7 rows)
326
327 /*+ HashJoin(t1 t2) */
328 EXPLAIN (COSTS false) EXECUTE p4 (10);
329 LOG:  pg_hint_plan:
330 used hint:
331 HashJoin(t1 t2)
332 not used hint:
333 duplication hint:
334 error hint:
335
336                    QUERY PLAN                    
337 -------------------------------------------------
338  Aggregate
339    ->  Hash Join
340          Hash Cond: (t1.id = t2.id)
341          ->  Index Only Scan using t1_pkey on t1
342                Index Cond: (id > $1)
343          ->  Hash
344                ->  Seq Scan on t2
345 (7 rows)
346
347 EXPLAIN (COSTS false) EXECUTE p4 (10);
348                    QUERY PLAN                    
349 -------------------------------------------------
350  Aggregate
351    ->  Hash Join
352          Hash Cond: (t1.id = t2.id)
353          ->  Index Only Scan using t1_pkey on t1
354                Index Cond: (id > $1)
355          ->  Hash
356                ->  Seq Scan on t2
357 (7 rows)
358
359 EXPLAIN (COSTS false) EXECUTE p4 (10);
360                    QUERY PLAN                    
361 -------------------------------------------------
362  Aggregate
363    ->  Hash Join
364          Hash Cond: (t1.id = t2.id)
365          ->  Index Only Scan using t1_pkey on t1
366                Index Cond: (id > $1)
367          ->  Hash
368                ->  Seq Scan on t2
369 (7 rows)
370
371 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
372 -- 9.2:6回目のEXPLAINでヒント句を指定すると、7回目以降も実行計画を制御できる
373 /*+ NestLoop(t1 t2) */
374 PREPARE p5 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > $1;
375 EXPLAIN (COSTS false) EXECUTE p5 (10);
376                    QUERY PLAN                    
377 -------------------------------------------------
378  Aggregate
379    ->  Merge Join
380          Merge Cond: (t1.id = t2.id)
381          ->  Index Only Scan using t1_pkey on t1
382                Index Cond: (id > 10)
383          ->  Index Only Scan using t2_pkey on t2
384 (6 rows)
385
386 EXPLAIN (COSTS false) EXECUTE p5 (10);
387                    QUERY PLAN                    
388 -------------------------------------------------
389  Aggregate
390    ->  Merge Join
391          Merge Cond: (t1.id = t2.id)
392          ->  Index Only Scan using t1_pkey on t1
393                Index Cond: (id > 10)
394          ->  Index Only Scan using t2_pkey on t2
395 (6 rows)
396
397 EXPLAIN (COSTS false) EXECUTE p5 (10);
398                    QUERY PLAN                    
399 -------------------------------------------------
400  Aggregate
401    ->  Merge Join
402          Merge Cond: (t1.id = t2.id)
403          ->  Index Only Scan using t1_pkey on t1
404                Index Cond: (id > 10)
405          ->  Index Only Scan using t2_pkey on t2
406 (6 rows)
407
408 EXPLAIN (COSTS false) EXECUTE p5 (10);
409                    QUERY PLAN                    
410 -------------------------------------------------
411  Aggregate
412    ->  Merge Join
413          Merge Cond: (t1.id = t2.id)
414          ->  Index Only Scan using t1_pkey on t1
415                Index Cond: (id > 10)
416          ->  Index Only Scan using t2_pkey on t2
417 (6 rows)
418
419 EXPLAIN (COSTS false) EXECUTE p5 (10);
420                    QUERY PLAN                    
421 -------------------------------------------------
422  Aggregate
423    ->  Merge Join
424          Merge Cond: (t1.id = t2.id)
425          ->  Index Only Scan using t1_pkey on t1
426                Index Cond: (id > 10)
427          ->  Index Only Scan using t2_pkey on t2
428 (6 rows)
429
430 /*+ HashJoin(t1 t2) */
431 EXPLAIN (COSTS false) EXECUTE p5 (10);
432 LOG:  pg_hint_plan:
433 used hint:
434 HashJoin(t1 t2)
435 not used hint:
436 duplication hint:
437 error hint:
438
439 LOG:  pg_hint_plan:
440 used hint:
441 HashJoin(t1 t2)
442 not used hint:
443 duplication hint:
444 error hint:
445
446              QUERY PLAN             
447 ------------------------------------
448  Aggregate
449    ->  Hash Join
450          Hash Cond: (t1.id = t2.id)
451          ->  Seq Scan on t1
452                Filter: (id > 10)
453          ->  Hash
454                ->  Seq Scan on t2
455 (7 rows)
456
457 /*+ HashJoin(t1 t2) */
458 EXPLAIN (COSTS false) EXECUTE p5 (10);
459 LOG:  pg_hint_plan:
460 used hint:
461 HashJoin(t1 t2)
462 not used hint:
463 duplication hint:
464 error hint:
465
466              QUERY PLAN             
467 ------------------------------------
468  Aggregate
469    ->  Hash Join
470          Hash Cond: (t1.id = t2.id)
471          ->  Seq Scan on t1
472                Filter: (id > 10)
473          ->  Hash
474                ->  Seq Scan on t2
475 (7 rows)
476
477 /*+ HashJoin(t1 t2) */
478 EXPLAIN (COSTS false) EXECUTE p5 (10);
479 LOG:  pg_hint_plan:
480 used hint:
481 HashJoin(t1 t2)
482 not used hint:
483 duplication hint:
484 error hint:
485
486              QUERY PLAN             
487 ------------------------------------
488  Aggregate
489    ->  Hash Join
490          Hash Cond: (t1.id = t2.id)
491          ->  Seq Scan on t1
492                Filter: (id > 10)
493          ->  Hash
494                ->  Seq Scan on t2
495 (7 rows)
496
497 -- 9.1:PREPAREで指定したヒント句で実行計画が固定される
498 -- 9.2:7回目以降のEXPLAINでヒント句を指定しても、以降も実行計画は制御できない
499 /*+ NestLoop(t1 t2) */
500 PREPARE p6 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > $1;
501 EXPLAIN (COSTS false) EXECUTE p6 (10);
502                    QUERY PLAN                    
503 -------------------------------------------------
504  Aggregate
505    ->  Merge Join
506          Merge Cond: (t1.id = t2.id)
507          ->  Index Only Scan using t1_pkey on t1
508                Index Cond: (id > 10)
509          ->  Index Only Scan using t2_pkey on t2
510 (6 rows)
511
512 EXPLAIN (COSTS false) EXECUTE p6 (10);
513                    QUERY PLAN                    
514 -------------------------------------------------
515  Aggregate
516    ->  Merge Join
517          Merge Cond: (t1.id = t2.id)
518          ->  Index Only Scan using t1_pkey on t1
519                Index Cond: (id > 10)
520          ->  Index Only Scan using t2_pkey on t2
521 (6 rows)
522
523 EXPLAIN (COSTS false) EXECUTE p6 (10);
524                    QUERY PLAN                    
525 -------------------------------------------------
526  Aggregate
527    ->  Merge Join
528          Merge Cond: (t1.id = t2.id)
529          ->  Index Only Scan using t1_pkey on t1
530                Index Cond: (id > 10)
531          ->  Index Only Scan using t2_pkey on t2
532 (6 rows)
533
534 EXPLAIN (COSTS false) EXECUTE p6 (10);
535                    QUERY PLAN                    
536 -------------------------------------------------
537  Aggregate
538    ->  Merge Join
539          Merge Cond: (t1.id = t2.id)
540          ->  Index Only Scan using t1_pkey on t1
541                Index Cond: (id > 10)
542          ->  Index Only Scan using t2_pkey on t2
543 (6 rows)
544
545 EXPLAIN (COSTS false) EXECUTE p6 (10);
546                    QUERY PLAN                    
547 -------------------------------------------------
548  Aggregate
549    ->  Merge Join
550          Merge Cond: (t1.id = t2.id)
551          ->  Index Only Scan using t1_pkey on t1
552                Index Cond: (id > 10)
553          ->  Index Only Scan using t2_pkey on t2
554 (6 rows)
555
556 EXPLAIN (COSTS false) EXECUTE p6 (10);
557                    QUERY PLAN                    
558 -------------------------------------------------
559  Aggregate
560    ->  Merge Join
561          Merge Cond: (t1.id = t2.id)
562          ->  Index Only Scan using t1_pkey on t1
563                Index Cond: (id > $1)
564          ->  Index Only Scan using t2_pkey on t2
565 (6 rows)
566
567 /*+ HashJoin(t1 t2) */
568 EXPLAIN (COSTS false) EXECUTE p6 (10);
569                    QUERY PLAN                    
570 -------------------------------------------------
571  Aggregate
572    ->  Merge Join
573          Merge Cond: (t1.id = t2.id)
574          ->  Index Only Scan using t1_pkey on t1
575                Index Cond: (id > $1)
576          ->  Index Only Scan using t2_pkey on t2
577 (6 rows)
578
579 /*+ HashJoin(t1 t2) */
580 EXPLAIN (COSTS false) EXECUTE p6 (10);
581                    QUERY PLAN                    
582 -------------------------------------------------
583  Aggregate
584    ->  Merge Join
585          Merge Cond: (t1.id = t2.id)
586          ->  Index Only Scan using t1_pkey on t1
587                Index Cond: (id > $1)
588          ->  Index Only Scan using t2_pkey on t2
589 (6 rows)
590
591 -- 9.1:実行計画が固定されたあと、ANALYZEをすると1回目のEXECUTEで実行計画が固定される
592 -- 9.2:実行計画が固定されたあと、ANALYZEをすると1回目のEXECUTEで実行計画が固定される
593 /*+ NestLoop(t1 t2) */
594 PREPARE p7 AS SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > $1;
595 /*+ HashJoin(t1 t2) */
596 EXPLAIN (COSTS false) EXECUTE p7 (10);
597 LOG:  pg_hint_plan:
598 used hint:
599 HashJoin(t1 t2)
600 not used hint:
601 duplication hint:
602 error hint:
603
604              QUERY PLAN             
605 ------------------------------------
606  Aggregate
607    ->  Hash Join
608          Hash Cond: (t1.id = t2.id)
609          ->  Seq Scan on t1
610                Filter: (id > 10)
611          ->  Hash
612                ->  Seq Scan on t2
613 (7 rows)
614
615 /*+ HashJoin(t1 t2) */
616 EXPLAIN (COSTS false) EXECUTE p7 (10);
617 LOG:  pg_hint_plan:
618 used hint:
619 HashJoin(t1 t2)
620 not used hint:
621 duplication hint:
622 error hint:
623
624              QUERY PLAN             
625 ------------------------------------
626  Aggregate
627    ->  Hash Join
628          Hash Cond: (t1.id = t2.id)
629          ->  Seq Scan on t1
630                Filter: (id > 10)
631          ->  Hash
632                ->  Seq Scan on t2
633 (7 rows)
634
635 /*+ HashJoin(t1 t2) */
636 EXPLAIN (COSTS false) EXECUTE p7 (10);
637 LOG:  pg_hint_plan:
638 used hint:
639 HashJoin(t1 t2)
640 not used hint:
641 duplication hint:
642 error hint:
643
644              QUERY PLAN             
645 ------------------------------------
646  Aggregate
647    ->  Hash Join
648          Hash Cond: (t1.id = t2.id)
649          ->  Seq Scan on t1
650                Filter: (id > 10)
651          ->  Hash
652                ->  Seq Scan on t2
653 (7 rows)
654
655 /*+ HashJoin(t1 t2) */
656 EXPLAIN (COSTS false) EXECUTE p7 (10);
657 LOG:  pg_hint_plan:
658 used hint:
659 HashJoin(t1 t2)
660 not used hint:
661 duplication hint:
662 error hint:
663
664              QUERY PLAN             
665 ------------------------------------
666  Aggregate
667    ->  Hash Join
668          Hash Cond: (t1.id = t2.id)
669          ->  Seq Scan on t1
670                Filter: (id > 10)
671          ->  Hash
672                ->  Seq Scan on t2
673 (7 rows)
674
675 /*+ HashJoin(t1 t2) */
676 EXPLAIN (COSTS false) EXECUTE p7 (10);
677 LOG:  pg_hint_plan:
678 used hint:
679 HashJoin(t1 t2)
680 not used hint:
681 duplication hint:
682 error hint:
683
684              QUERY PLAN             
685 ------------------------------------
686  Aggregate
687    ->  Hash Join
688          Hash Cond: (t1.id = t2.id)
689          ->  Seq Scan on t1
690                Filter: (id > 10)
691          ->  Hash
692                ->  Seq Scan on t2
693 (7 rows)
694
695 /*+ HashJoin(t1 t2) */
696 EXPLAIN (COSTS false) EXECUTE p7 (10);
697 LOG:  pg_hint_plan:
698 used hint:
699 HashJoin(t1 t2)
700 not used hint:
701 duplication hint:
702 error hint:
703
704                    QUERY PLAN                    
705 -------------------------------------------------
706  Aggregate
707    ->  Hash Join
708          Hash Cond: (t1.id = t2.id)
709          ->  Index Only Scan using t1_pkey on t1
710                Index Cond: (id > $1)
711          ->  Hash
712                ->  Seq Scan on t2
713 (7 rows)
714
715 EXPLAIN (COSTS false) EXECUTE p7 (10);
716                    QUERY PLAN                    
717 -------------------------------------------------
718  Aggregate
719    ->  Hash Join
720          Hash Cond: (t1.id = t2.id)
721          ->  Index Only Scan using t1_pkey on t1
722                Index Cond: (id > $1)
723          ->  Hash
724                ->  Seq Scan on t2
725 (7 rows)
726
727 EXPLAIN (COSTS false) EXECUTE p7 (10);
728                    QUERY PLAN                    
729 -------------------------------------------------
730  Aggregate
731    ->  Hash Join
732          Hash Cond: (t1.id = t2.id)
733          ->  Index Only Scan using t1_pkey on t1
734                Index Cond: (id > $1)
735          ->  Hash
736                ->  Seq Scan on t2
737 (7 rows)
738
739 TRUNCATE t1;
740 ANALYZE t1;
741 EXPLAIN (COSTS false) SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > 10;
742                    QUERY PLAN                    
743 -------------------------------------------------
744  Aggregate
745    ->  Merge Join
746          Merge Cond: (t1.id = t2.id)
747          ->  Index Only Scan using t1_pkey on t1
748                Index Cond: (id > 10)
749          ->  Index Only Scan using t2_pkey on t2
750 (6 rows)
751
752 EXPLAIN (COSTS false) EXECUTE p7 (10);
753                    QUERY PLAN                    
754 -------------------------------------------------
755  Aggregate
756    ->  Merge Join
757          Merge Cond: (t1.id = t2.id)
758          ->  Index Only Scan using t1_pkey on t1
759                Index Cond: (id > $1)
760          ->  Index Only Scan using t2_pkey on t2
761 (6 rows)
762
763 /*+ HashJoin(t1 t2) */
764 EXPLAIN (COSTS false) EXECUTE p7 (10);
765                    QUERY PLAN                    
766 -------------------------------------------------
767  Aggregate
768    ->  Merge Join
769          Merge Cond: (t1.id = t2.id)
770          ->  Index Only Scan using t1_pkey on t1
771                Index Cond: (id > $1)
772          ->  Index Only Scan using t2_pkey on t2
773 (6 rows)
774
775 INSERT INTO t1 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t;
776 ANALYZE t1;
777 EXPLAIN (COSTS false) SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > 10;
778                    QUERY PLAN                    
779 -------------------------------------------------
780  Aggregate
781    ->  Merge Join
782          Merge Cond: (t1.id = t2.id)
783          ->  Index Only Scan using t1_pkey on t1
784                Index Cond: (id > 10)
785          ->  Index Only Scan using t2_pkey on t2
786 (6 rows)
787
788 /*+ HashJoin(t1 t2) */
789 EXPLAIN (COSTS false) EXECUTE p7 (10);
790 LOG:  /*
791 HashJoin(t1 t2)
792
793                    QUERY PLAN                    
794 -------------------------------------------------
795  Aggregate
796    ->  Hash Join
797          Hash Cond: (t1.id = t2.id)
798          ->  Index Only Scan using t1_pkey on t1
799                Index Cond: (id > $1)
800          ->  Hash
801                ->  Seq Scan on t2
802 (7 rows)
803
804 /*+ NestLoop(t1 t2) */
805 EXPLAIN (COSTS false) EXECUTE p7 (10);
806                    QUERY PLAN                    
807 -------------------------------------------------
808  Aggregate
809    ->  Hash Join
810          Hash Cond: (t1.id = t2.id)
811          ->  Index Only Scan using t1_pkey on t1
812                Index Cond: (id > $1)
813          ->  Hash
814                ->  Seq Scan on t2
815 (7 rows)
816
817 -- error case
818 /*+ NestLoop(t1 t2) */
819 EXPLAIN (COSTS false) EXECUTE p8 (10);
820 ERROR:  prepared statement "p8" does not exist
821 /*+ NestLoop(t1 t2) */
822 EXPLAIN (COSTS false) SELECT count(*) FROM t1, t2 WHERE t1.id = t2.id AND t1.id > 10;
823 LOG:  pg_hint_plan:
824 used hint:
825 NestLoop(t1 t2)
826 not used hint:
827 duplication hint:
828 error hint:
829
830                        QUERY PLAN                       
831 --------------------------------------------------------
832  Aggregate
833    ->  Nested Loop
834          ->  Seq Scan on t2
835          ->  Index Scan using t1_pkey on t1
836                Index Cond: ((id > 10) AND (id = t2.id))
837 (5 rows)
838