blob: c4b769dd4b77cc064919cbd750ce3db905ea7823 (
plain)
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
89
90
91
|
-- enum check
create type rainbow as enum ('r','o','y','g','b','i','v');
CREATE TABLE enumtmp (a rainbow);
\copy enumtmp from 'data/enum.data'
SET enable_seqscan=on;
select a, count(*) from enumtmp group by a order by 1;
a | count
---+-------
r | 76
o | 78
y | 73
g | 75
b | 77
i | 78
v | 75
| 63
(8 rows)
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
count
-------
227
(1 row)
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
count
-------
302
(1 row)
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
count
-------
75
(1 row)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
count
-------
305
(1 row)
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
count
-------
230
(1 row)
CREATE INDEX enumidx ON enumtmp USING gist ( a );
SET enable_seqscan=off;
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
count
-------
227
(1 row)
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
count
-------
302
(1 row)
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
count
-------
75
(1 row)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
count
-------
305
(1 row)
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
count
-------
230
(1 row)
EXPLAIN (COSTS OFF)
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
QUERY PLAN
-----------------------------------------------
Aggregate
-> Bitmap Heap Scan on enumtmp
Recheck Cond: (a >= 'g'::rainbow)
-> Bitmap Index Scan on enumidx
Index Cond: (a >= 'g'::rainbow)
(5 rows)
|