1- CREATE TABLE atsts (id int, t tsvector, d timestamp);
2- \copy atsts from 'data/tsts.data'
3- CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_hash_addon_ops, d)
1+ CREATE TABLE atstsh (id int, t tsvector, d timestamp);
2+ \copy atstsh from 'data/tsts.data'
3+ CREATE INDEX atstsh_idx ON atstsh USING rum (t rum_tsvector_hash_addon_ops, d)
44 WITH (attach = 'd', to = 't', order_by_attach='t');
5- INSERT INTO atsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
6- INSERT INTO atsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
7- SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
5+ INSERT INTO atstsh VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
6+ INSERT INTO atstsh VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
7+ SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
88 count
99-------
1010 158
1111(1 row)
1212
13- SELECT count(*) FROM atsts WHERE t @@ 'wr&qh';
13+ SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
1414 count
1515-------
1616 17
1717(1 row)
1818
19- SELECT count(*) FROM atsts WHERE t @@ 'eq&yt';
19+ SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
2020 count
2121-------
2222 6
2323(1 row)
2424
25- SELECT count(*) FROM atsts WHERE t @@ 'eq|yt';
25+ SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
2626 count
2727-------
2828 98
2929(1 row)
3030
31- SELECT count(*) FROM atsts WHERE t @@ '(eq&yt)|(wr&qh)';
31+ SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
3232 count
3333-------
3434 23
3535(1 row)
3636
37- SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
37+ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
3838 count
3939-------
4040 39
@@ -43,7 +43,7 @@ SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
4343SET enable_indexscan=OFF;
4444SET enable_indexonlyscan=OFF;
4545SET enable_bitmapscan=OFF;
46- SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
46+ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
4747 id | d | ?column?
4848-----+---------------------------------+---------------
4949 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
@@ -53,7 +53,7 @@ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
5353 415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
5454(5 rows)
5555
56- SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
56+ SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
5757 id | d | ?column?
5858-----+---------------------------------+---------------
5959 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
@@ -63,7 +63,7 @@ SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
6363 168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
6464(5 rows)
6565
66- SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
66+ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
6767 id | d | ?column?
6868-----+---------------------------------+---------------
6969 371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
@@ -73,19 +73,19 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
7373 457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
7474(5 rows)
7575
76- SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
76+ SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
7777 count
7878-------
7979 357
8080(1 row)
8181
82- SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
82+ SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
8383 count
8484-------
8585 153
8686(1 row)
8787
88- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
88+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
8989 id | d
9090-----+---------------------------------
9191 16 | Mon May 02 11:21:22.326724 2016
@@ -99,7 +99,7 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
9999 355 | Mon May 16 14:21:22.326724 2016
100100(9 rows)
101101
102- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
102+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
103103 id | d
104104-----+---------------------------------
105105 371 | Tue May 17 06:21:22.326724 2016
@@ -117,97 +117,97 @@ RESET enable_indexonlyscan;
117117RESET enable_bitmapscan;
118118SET enable_seqscan = off;
119119EXPLAIN (costs off)
120- SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
120+ SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
121121 QUERY PLAN
122122-------------------------------------------------------------
123123 Aggregate
124- -> Bitmap Heap Scan on atsts
124+ -> Bitmap Heap Scan on atstsh
125125 Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
126- -> Bitmap Index Scan on atsts_idx
126+ -> Bitmap Index Scan on atstsh_idx
127127 Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
128128(5 rows)
129129
130- SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
130+ SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
131131 count
132132-------
133133 158
134134(1 row)
135135
136- SELECT count(*) FROM atsts WHERE t @@ 'wr&qh';
136+ SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
137137 count
138138-------
139139 17
140140(1 row)
141141
142- SELECT count(*) FROM atsts WHERE t @@ 'eq&yt';
142+ SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
143143 count
144144-------
145145 6
146146(1 row)
147147
148- SELECT count(*) FROM atsts WHERE t @@ 'eq|yt';
148+ SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
149149 count
150150-------
151151 98
152152(1 row)
153153
154- SELECT count(*) FROM atsts WHERE t @@ '(eq&yt)|(wr&qh)';
154+ SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
155155 count
156156-------
157157 23
158158(1 row)
159159
160- SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
160+ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
161161 count
162162-------
163163 39
164164(1 row)
165165
166166EXPLAIN (costs off)
167- SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
167+ SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
168168 QUERY PLAN
169169-----------------------------------------------------------------------------------------
170170 Aggregate
171- -> Bitmap Heap Scan on atsts
171+ -> Bitmap Heap Scan on atstsh
172172 Recheck Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
173- -> Bitmap Index Scan on atsts_idx
173+ -> Bitmap Index Scan on atstsh_idx
174174 Index Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
175175(5 rows)
176176
177- SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
177+ SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
178178 count
179179-------
180180 357
181181(1 row)
182182
183183EXPLAIN (costs off)
184- SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
184+ SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
185185 QUERY PLAN
186186-----------------------------------------------------------------------------------------
187187 Aggregate
188- -> Bitmap Heap Scan on atsts
188+ -> Bitmap Heap Scan on atstsh
189189 Recheck Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
190- -> Bitmap Index Scan on atsts_idx
190+ -> Bitmap Index Scan on atstsh_idx
191191 Index Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
192192(5 rows)
193193
194- SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
194+ SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
195195 count
196196-------
197197 153
198198(1 row)
199199
200200EXPLAIN (costs off)
201- SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
201+ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
202202 QUERY PLAN
203203-----------------------------------------------------------------------------------
204204 Limit
205- -> Index Scan using atsts_idx on atsts
205+ -> Index Scan using atstsh_idx on atstsh
206206 Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
207207 Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
208208(4 rows)
209209
210- SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
210+ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
211211 id | d | ?column?
212212-----+---------------------------------+---------------
213213 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
@@ -218,16 +218,16 @@ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
218218(5 rows)
219219
220220EXPLAIN (costs off)
221- SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
221+ SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
222222 QUERY PLAN
223223-----------------------------------------------------------------------------------
224224 Limit
225- -> Index Scan using atsts_idx on atsts
225+ -> Index Scan using atstsh_idx on atstsh
226226 Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
227227 Order By: (d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone)
228228(4 rows)
229229
230- SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
230+ SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d <=| '2016-05-16 14:21:25' LIMIT 5;
231231 id | d | ?column?
232232-----+---------------------------------+---------------
233233 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
@@ -238,16 +238,16 @@ SELECT id, d, d <=| '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
238238(5 rows)
239239
240240EXPLAIN (costs off)
241- SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
241+ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
242242 QUERY PLAN
243243-----------------------------------------------------------------------------------
244244 Limit
245- -> Index Scan using atsts_idx on atsts
245+ -> Index Scan using atstsh_idx on atstsh
246246 Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
247247 Order By: (d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
248248(4 rows)
249249
250- SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
250+ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atstsh WHERE t @@ 'wr&qh' ORDER BY d |=> '2016-05-16 14:21:25' LIMIT 5;
251251 id | d | ?column?
252252-----+---------------------------------+---------------
253253 371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
@@ -258,15 +258,15 @@ SELECT id, d, d |=> '2016-05-16 14:21:25' FROM atsts WHERE t @@ 'wr&qh' ORDER BY
258258(5 rows)
259259
260260EXPLAIN (costs off)
261- SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
261+ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
262262 QUERY PLAN
263263-----------------------------------------------------------------------------------
264264 Limit
265- -> Index Scan using atsts_idx on atsts
265+ -> Index Scan using atstsh_idx on atstsh
266266 Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
267267(3 rows)
268268
269- SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
269+ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
270270 id | d | ?column?
271271-----+---------------------------------+-------------
272272 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
@@ -277,16 +277,16 @@ SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16
277277(5 rows)
278278
279279EXPLAIN (costs off)
280- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
280+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
281281 QUERY PLAN
282282----------------------------------------------------------------------------------------------------------------------------
283283 Sort
284284 Sort Key: d
285- -> Index Scan using atsts_idx on atsts
285+ -> Index Scan using atstsh_idx on atstsh
286286 Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
287287(4 rows)
288288
289- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
289+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
290290 id | d
291291-----+---------------------------------
292292 16 | Mon May 02 11:21:22.326724 2016
@@ -301,16 +301,16 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
301301(9 rows)
302302
303303EXPLAIN (costs off)
304- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
304+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
305305 QUERY PLAN
306306----------------------------------------------------------------------------------------------------------------------------
307307 Sort
308308 Sort Key: d
309- -> Index Scan using atsts_idx on atsts
309+ -> Index Scan using atstsh_idx on atstsh
310310 Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
311311(4 rows)
312312
313- SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
313+ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
314314 id | d
315315-----+---------------------------------
316316 371 | Tue May 17 06:21:22.326724 2016
@@ -323,4 +323,3 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
323323 496 | Sun May 22 11:21:22.326724 2016
324324(8 rows)
325325
326- DROP TABLE atsts CASCADE;
0 commit comments