OSDN Git Service

d5fe9e087baa14fafa94f35260a3c52d00451f20
[pghintplan/pg_hint_plan.git] / expected / ut-T.out
1 -- ut-T: tests for table hints
2 -- This test is focusing on hint retrieval from table
3 LOAD 'pg_hint_plan';
4 SET pg_hint_plan.enable_hint TO on;
5 SET pg_hint_plan.debug_print TO on;
6 SET client_min_messages TO LOG;
7 SET search_path TO public;
8 -- test for get_query_string
9 INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)');
10 INSERT INTO hint_plan.hints VALUES(DEFAULT,'PREPARE p1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)');
11 INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)');
12 INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)');
13 PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
14 -- These queries uses IndexScan without hints
15 SET pg_hint_plan.enable_hint_table to off;
16 EXPLAIN SELECT * FROM t1 WHERE id = 100;
17                             QUERY PLAN                            
18 ------------------------------------------------------------------
19  Index Scan using t1_pkey on t1  (cost=0.29..8.30 rows=1 width=8)
20    Index Cond: (id = 100)
21 (2 rows)
22
23 EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100;
24                             QUERY PLAN                            
25 ------------------------------------------------------------------
26  Index Scan using t1_pkey on t1  (cost=0.29..8.30 rows=1 width=8)
27    Index Cond: (id = 100)
28 (2 rows)
29
30 EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100;
31                             QUERY PLAN                            
32 ------------------------------------------------------------------
33  Index Scan using t1_pkey on t1  (cost=0.29..8.30 rows=1 width=8)
34    Index Cond: (id = 100)
35 (2 rows)
36
37 EXPLAIN EXECUTE p1;
38                             QUERY PLAN                            
39 ------------------------------------------------------------------
40  Index Scan using t1_pkey on t1  (cost=0.29..8.30 rows=1 width=8)
41    Index Cond: (id = 100)
42 (2 rows)
43
44 DEALLOCATE p1;
45 PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
46 EXPLAIN CREATE TABLE ct1 AS EXECUTE p1;
47                             QUERY PLAN                            
48 ------------------------------------------------------------------
49  Index Scan using t1_pkey on t1  (cost=0.29..8.30 rows=1 width=8)
50    Index Cond: (id = 100)
51 (2 rows)
52
53 DEALLOCATE p1;
54 PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
55 -- Forced to use SeqScan by table hints
56 SET pg_hint_plan.enable_hint_table to on;
57 EXPLAIN SELECT * FROM t1 WHERE id = 100;
58 LOG:  pg_hint_plan:
59 used hint:
60 SeqScan(t1)
61 not used hint:
62 duplication hint:
63 error hint:
64
65                      QUERY PLAN                     
66 ----------------------------------------------------
67  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
68    Filter: (id = 100)
69 (2 rows)
70
71 EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100;
72 LOG:  pg_hint_plan:
73 used hint:
74 SeqScan(t1)
75 not used hint:
76 duplication hint:
77 error hint:
78
79                      QUERY PLAN                     
80 ----------------------------------------------------
81  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
82    Filter: (id = 100)
83 (2 rows)
84
85 EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100;
86 LOG:  pg_hint_plan:
87 used hint:
88 SeqScan(t1)
89 not used hint:
90 duplication hint:
91 error hint:
92
93                      QUERY PLAN                     
94 ----------------------------------------------------
95  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
96    Filter: (id = 100)
97 (2 rows)
98
99 EXPLAIN EXECUTE p1;
100 LOG:  pg_hint_plan:
101 used hint:
102 SeqScan(t1)
103 not used hint:
104 duplication hint:
105 error hint:
106
107                      QUERY PLAN                     
108 ----------------------------------------------------
109  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
110    Filter: (id = 100)
111 (2 rows)
112
113 DEALLOCATE p1;
114 PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
115 EXPLAIN CREATE TABLE ct1 AS EXECUTE p1;
116 LOG:  pg_hint_plan:
117 used hint:
118 SeqScan(t1)
119 not used hint:
120 duplication hint:
121 error hint:
122
123                      QUERY PLAN                     
124 ----------------------------------------------------
125  Seq Scan on t1  (cost=0.00..170.00 rows=1 width=8)
126    Filter: (id = 100)
127 (2 rows)
128
129 DEALLOCATE p1;
130 SET pg_hint_plan.enable_hint_table to off;
131 DELETE FROM hint_plan.hints;