forked from ossc-db/pg_hint_plan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathut-T.out
88 lines (79 loc) · 2.15 KB
/
ut-T.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- ut-T: tests for table hints
-- This test is focusing on hint retrieval from table
LOAD 'pg_hint_plan';
SET pg_hint_plan.enable_hint TO on;
SET pg_hint_plan.debug_print TO on;
SET client_min_messages TO LOG;
SET search_path TO public;
-- This hint affects queries with an equivalent query ID when executed as
-- a subquery.
SELECT get_query_id('SELECT * FROM t1 WHERE id = 1;') AS query_id \gset
INSERT INTO hint_plan.hints VALUES (DEFAULT, :'query_id', '', 'SeqScan(t1)');
PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
-- These queries uses IndexScan without hints
SET pg_hint_plan.enable_hint_table to off;
EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100;
QUERY PLAN
--------------------------------
Index Scan using t1_pkey on t1
Index Cond: (id = 100)
(2 rows)
EXPLAIN (COSTS false) EXECUTE p1;
QUERY PLAN
--------------------------------
Index Scan using t1_pkey on t1
Index Cond: (id = 100)
(2 rows)
DEALLOCATE p1;
PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1;
QUERY PLAN
--------------------------------
Index Scan using t1_pkey on t1
Index Cond: (id = 100)
(2 rows)
DEALLOCATE p1;
PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
-- Forced to use SeqScan by table hints
SET pg_hint_plan.enable_hint_table to on;
EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100;
LOG: pg_hint_plan:
used hint:
SeqScan(t1)
not used hint:
duplication hint:
error hint:
QUERY PLAN
----------------------
Seq Scan on t1
Filter: (id = 100)
(2 rows)
EXPLAIN (COSTS false) EXECUTE p1;
LOG: pg_hint_plan:
used hint:
SeqScan(t1)
not used hint:
duplication hint:
error hint:
QUERY PLAN
----------------------
Seq Scan on t1
Filter: (id = 100)
(2 rows)
DEALLOCATE p1;
PREPARE p1 AS SELECT * FROM t1 WHERE id = 100;
EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1;
LOG: pg_hint_plan:
used hint:
SeqScan(t1)
not used hint:
duplication hint:
error hint:
QUERY PLAN
----------------------
Seq Scan on t1
Filter: (id = 100)
(2 rows)
DEALLOCATE p1;
SET pg_hint_plan.enable_hint_table to off;
DELETE FROM hint_plan.hints;