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)
4
4
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';
8
8
count
9
9
-------
10
10
158
11
11
(1 row)
12
12
13
- SELECT count(*) FROM atsts WHERE t @@ 'wr&qh';
13
+ SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
14
14
count
15
15
-------
16
16
17
17
17
(1 row)
18
18
19
- SELECT count(*) FROM atsts WHERE t @@ 'eq&yt';
19
+ SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
20
20
count
21
21
-------
22
22
6
23
23
(1 row)
24
24
25
- SELECT count(*) FROM atsts WHERE t @@ 'eq|yt';
25
+ SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
26
26
count
27
27
-------
28
28
98
29
29
(1 row)
30
30
31
- SELECT count(*) FROM atsts WHERE t @@ '(eq&yt)|(wr&qh)';
31
+ SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
32
32
count
33
33
-------
34
34
23
35
35
(1 row)
36
36
37
- SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
37
+ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
38
38
count
39
39
-------
40
40
39
@@ -43,7 +43,7 @@ SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
43
43
SET enable_indexscan=OFF;
44
44
SET enable_indexonlyscan=OFF;
45
45
SET 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;
47
47
id | d | ?column?
48
48
-----+---------------------------------+---------------
49
49
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
53
53
415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
54
54
(5 rows)
55
55
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;
57
57
id | d | ?column?
58
58
-----+---------------------------------+---------------
59
59
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
63
63
168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
64
64
(5 rows)
65
65
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;
67
67
id | d | ?column?
68
68
-----+---------------------------------+---------------
69
69
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
73
73
457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
74
74
(5 rows)
75
75
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';
77
77
count
78
78
-------
79
79
357
80
80
(1 row)
81
81
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';
83
83
count
84
84
-------
85
85
153
86
86
(1 row)
87
87
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;
89
89
id | d
90
90
-----+---------------------------------
91
91
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
99
99
355 | Mon May 16 14:21:22.326724 2016
100
100
(9 rows)
101
101
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;
103
103
id | d
104
104
-----+---------------------------------
105
105
371 | Tue May 17 06:21:22.326724 2016
@@ -117,97 +117,97 @@ RESET enable_indexonlyscan;
117
117
RESET enable_bitmapscan;
118
118
SET enable_seqscan = off;
119
119
EXPLAIN (costs off)
120
- SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
120
+ SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
121
121
QUERY PLAN
122
122
-------------------------------------------------------------
123
123
Aggregate
124
- -> Bitmap Heap Scan on atsts
124
+ -> Bitmap Heap Scan on atstsh
125
125
Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
126
- -> Bitmap Index Scan on atsts_idx
126
+ -> Bitmap Index Scan on atstsh_idx
127
127
Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
128
128
(5 rows)
129
129
130
- SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
130
+ SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
131
131
count
132
132
-------
133
133
158
134
134
(1 row)
135
135
136
- SELECT count(*) FROM atsts WHERE t @@ 'wr&qh';
136
+ SELECT count(*) FROM atstsh WHERE t @@ 'wr&qh';
137
137
count
138
138
-------
139
139
17
140
140
(1 row)
141
141
142
- SELECT count(*) FROM atsts WHERE t @@ 'eq&yt';
142
+ SELECT count(*) FROM atstsh WHERE t @@ 'eq&yt';
143
143
count
144
144
-------
145
145
6
146
146
(1 row)
147
147
148
- SELECT count(*) FROM atsts WHERE t @@ 'eq|yt';
148
+ SELECT count(*) FROM atstsh WHERE t @@ 'eq|yt';
149
149
count
150
150
-------
151
151
98
152
152
(1 row)
153
153
154
- SELECT count(*) FROM atsts WHERE t @@ '(eq&yt)|(wr&qh)';
154
+ SELECT count(*) FROM atstsh WHERE t @@ '(eq&yt)|(wr&qh)';
155
155
count
156
156
-------
157
157
23
158
158
(1 row)
159
159
160
- SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
160
+ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
161
161
count
162
162
-------
163
163
39
164
164
(1 row)
165
165
166
166
EXPLAIN (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';
168
168
QUERY PLAN
169
169
-----------------------------------------------------------------------------------------
170
170
Aggregate
171
- -> Bitmap Heap Scan on atsts
171
+ -> Bitmap Heap Scan on atstsh
172
172
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
174
174
Index Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
175
175
(5 rows)
176
176
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';
178
178
count
179
179
-------
180
180
357
181
181
(1 row)
182
182
183
183
EXPLAIN (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';
185
185
QUERY PLAN
186
186
-----------------------------------------------------------------------------------------
187
187
Aggregate
188
- -> Bitmap Heap Scan on atsts
188
+ -> Bitmap Heap Scan on atstsh
189
189
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
191
191
Index Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
192
192
(5 rows)
193
193
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';
195
195
count
196
196
-------
197
197
153
198
198
(1 row)
199
199
200
200
EXPLAIN (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;
202
202
QUERY PLAN
203
203
-----------------------------------------------------------------------------------
204
204
Limit
205
- -> Index Scan using atsts_idx on atsts
205
+ -> Index Scan using atstsh_idx on atstsh
206
206
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
207
207
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
208
208
(4 rows)
209
209
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;
211
211
id | d | ?column?
212
212
-----+---------------------------------+---------------
213
213
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
218
218
(5 rows)
219
219
220
220
EXPLAIN (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;
222
222
QUERY PLAN
223
223
-----------------------------------------------------------------------------------
224
224
Limit
225
- -> Index Scan using atsts_idx on atsts
225
+ -> Index Scan using atstsh_idx on atstsh
226
226
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
227
227
Order By: (d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone)
228
228
(4 rows)
229
229
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;
231
231
id | d | ?column?
232
232
-----+---------------------------------+---------------
233
233
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
238
238
(5 rows)
239
239
240
240
EXPLAIN (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;
242
242
QUERY PLAN
243
243
-----------------------------------------------------------------------------------
244
244
Limit
245
- -> Index Scan using atsts_idx on atsts
245
+ -> Index Scan using atstsh_idx on atstsh
246
246
Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
247
247
Order By: (d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
248
248
(4 rows)
249
249
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;
251
251
id | d | ?column?
252
252
-----+---------------------------------+---------------
253
253
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
258
258
(5 rows)
259
259
260
260
EXPLAIN (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;
262
262
QUERY PLAN
263
263
-----------------------------------------------------------------------------------
264
264
Limit
265
- -> Index Scan using atsts_idx on atsts
265
+ -> Index Scan using atstsh_idx on atstsh
266
266
Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
267
267
(3 rows)
268
268
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;
270
270
id | d | ?column?
271
271
-----+---------------------------------+-------------
272
272
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
277
277
(5 rows)
278
278
279
279
EXPLAIN (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;
281
281
QUERY PLAN
282
282
----------------------------------------------------------------------------------------------------------------------------
283
283
Sort
284
284
Sort Key: d
285
- -> Index Scan using atsts_idx on atsts
285
+ -> Index Scan using atstsh_idx on atstsh
286
286
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
287
287
(4 rows)
288
288
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;
290
290
id | d
291
291
-----+---------------------------------
292
292
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
301
301
(9 rows)
302
302
303
303
EXPLAIN (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;
305
305
QUERY PLAN
306
306
----------------------------------------------------------------------------------------------------------------------------
307
307
Sort
308
308
Sort Key: d
309
- -> Index Scan using atsts_idx on atsts
309
+ -> Index Scan using atstsh_idx on atstsh
310
310
Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
311
311
(4 rows)
312
312
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;
314
314
id | d
315
315
-----+---------------------------------
316
316
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
323
323
496 | Sun May 22 11:21:22.326724 2016
324
324
(8 rows)
325
325
326
- DROP TABLE atsts CASCADE;
0 commit comments