]> granicus.if.org Git - postgresql/blob - contrib/bloom/expected/bloom.out
cbc50f757b65af892094faf4082951ef5caa89d2
[postgresql] / contrib / bloom / expected / bloom.out
1 CREATE EXTENSION bloom;
2 CREATE TABLE tst (
3         i       int4,
4         t       text
5 );
6 INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
7 CREATE INDEX bloomidx ON tst USING bloom (i, t) WITH (col1 = 3);
8 SET enable_seqscan=on;
9 SET enable_bitmapscan=off;
10 SET enable_indexscan=off;
11 SELECT count(*) FROM tst WHERE i = 7;
12  count 
13 -------
14    200
15 (1 row)
16
17 SELECT count(*) FROM tst WHERE t = '5';
18  count 
19 -------
20    112
21 (1 row)
22
23 SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
24  count 
25 -------
26     13
27 (1 row)
28
29 SET enable_seqscan=off;
30 SET enable_bitmapscan=on;
31 SET enable_indexscan=on;
32 EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE i = 7;
33                 QUERY PLAN                 
34 -------------------------------------------
35  Aggregate
36    ->  Bitmap Heap Scan on tst
37          Recheck Cond: (i = 7)
38          ->  Bitmap Index Scan on bloomidx
39                Index Cond: (i = 7)
40 (5 rows)
41
42 EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE t = '5';
43                 QUERY PLAN                 
44 -------------------------------------------
45  Aggregate
46    ->  Bitmap Heap Scan on tst
47          Recheck Cond: (t = '5'::text)
48          ->  Bitmap Index Scan on bloomidx
49                Index Cond: (t = '5'::text)
50 (5 rows)
51
52 EXPLAIN (COSTS OFF) SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
53                        QUERY PLAN                        
54 ---------------------------------------------------------
55  Aggregate
56    ->  Bitmap Heap Scan on tst
57          Recheck Cond: ((i = 7) AND (t = '5'::text))
58          ->  Bitmap Index Scan on bloomidx
59                Index Cond: ((i = 7) AND (t = '5'::text))
60 (5 rows)
61
62 SELECT count(*) FROM tst WHERE i = 7;
63  count 
64 -------
65    200
66 (1 row)
67
68 SELECT count(*) FROM tst WHERE t = '5';
69  count 
70 -------
71    112
72 (1 row)
73
74 SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
75  count 
76 -------
77     13
78 (1 row)
79
80 DELETE FROM tst;
81 INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
82 VACUUM ANALYZE tst;
83 SELECT count(*) FROM tst WHERE i = 7;
84  count 
85 -------
86    200
87 (1 row)
88
89 SELECT count(*) FROM tst WHERE t = '5';
90  count 
91 -------
92    112
93 (1 row)
94
95 SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
96  count 
97 -------
98     13
99 (1 row)
100
101 DELETE FROM tst WHERE i > 1 OR t = '5';
102 VACUUM tst;
103 INSERT INTO tst SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
104 SELECT count(*) FROM tst WHERE i = 7;
105  count 
106 -------
107    200
108 (1 row)
109
110 SELECT count(*) FROM tst WHERE t = '5';
111  count 
112 -------
113    112
114 (1 row)
115
116 SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
117  count 
118 -------
119     13
120 (1 row)
121
122 VACUUM FULL tst;
123 SELECT count(*) FROM tst WHERE i = 7;
124  count 
125 -------
126    200
127 (1 row)
128
129 SELECT count(*) FROM tst WHERE t = '5';
130  count 
131 -------
132    112
133 (1 row)
134
135 SELECT count(*) FROM tst WHERE i = 7 AND t = '5';
136  count 
137 -------
138     13
139 (1 row)
140
141 -- Try an unlogged table too
142 CREATE UNLOGGED TABLE tstu (
143         i       int4,
144         t       text
145 );
146 INSERT INTO tstu SELECT i%10, substr(md5(i::text), 1, 1) FROM generate_series(1,2000) i;
147 CREATE INDEX bloomidxu ON tstu USING bloom (i, t) WITH (col2 = 4);
148 SET enable_seqscan=off;
149 SET enable_bitmapscan=on;
150 SET enable_indexscan=on;
151 EXPLAIN (COSTS OFF) SELECT count(*) FROM tstu WHERE i = 7;
152                  QUERY PLAN                 
153 --------------------------------------------
154  Aggregate
155    ->  Bitmap Heap Scan on tstu
156          Recheck Cond: (i = 7)
157          ->  Bitmap Index Scan on bloomidxu
158                Index Cond: (i = 7)
159 (5 rows)
160
161 EXPLAIN (COSTS OFF) SELECT count(*) FROM tstu WHERE t = '5';
162                  QUERY PLAN                 
163 --------------------------------------------
164  Aggregate
165    ->  Bitmap Heap Scan on tstu
166          Recheck Cond: (t = '5'::text)
167          ->  Bitmap Index Scan on bloomidxu
168                Index Cond: (t = '5'::text)
169 (5 rows)
170
171 EXPLAIN (COSTS OFF) SELECT count(*) FROM tstu WHERE i = 7 AND t = '5';
172                        QUERY PLAN                        
173 ---------------------------------------------------------
174  Aggregate
175    ->  Bitmap Heap Scan on tstu
176          Recheck Cond: ((i = 7) AND (t = '5'::text))
177          ->  Bitmap Index Scan on bloomidxu
178                Index Cond: ((i = 7) AND (t = '5'::text))
179 (5 rows)
180
181 SELECT count(*) FROM tstu WHERE i = 7;
182  count 
183 -------
184    200
185 (1 row)
186
187 SELECT count(*) FROM tstu WHERE t = '5';
188  count 
189 -------
190    112
191 (1 row)
192
193 SELECT count(*) FROM tstu WHERE i = 7 AND t = '5';
194  count 
195 -------
196     13
197 (1 row)
198
199 RESET enable_seqscan;
200 RESET enable_bitmapscan;
201 RESET enable_indexscan;
202 -- Run amvalidator function on our opclasses
203 SELECT opcname, amvalidate(opc.oid)
204 FROM pg_opclass opc JOIN pg_am am ON am.oid = opcmethod
205 WHERE amname = 'bloom'
206 ORDER BY 1;
207  opcname  | amvalidate 
208 ----------+------------
209  int4_ops | t
210  text_ops | t
211 (2 rows)
212