1
1
CREATE TABLE atsts (id int, t tsvector, d timestamp);
2
2
\copy atsts from 'data/tsts.data'
3
- CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_timestamp_ops , d)
3
+ CREATE INDEX atsts_idx ON atsts USING rum (t rum_tsvector_addon_ops , d)
4
4
WITH (attach = 'd', to = 't', order_by_attach='t');
5
- ERROR: currently, RUM doesn't support order by over pass-by-reference column
6
5
INSERT INTO atsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
7
6
INSERT INTO atsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
8
7
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
@@ -119,12 +118,14 @@ RESET enable_bitmapscan;
119
118
SET enable_seqscan = off;
120
119
EXPLAIN (costs off)
121
120
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
122
- QUERY PLAN
123
- ---------------------------------------------------
121
+ QUERY PLAN
122
+ -------------------------------------------------------------
124
123
Aggregate
125
- -> Seq Scan on atsts
126
- Filter: (t @@ '''wr'' | ''qh'''::tsquery)
127
- (3 rows)
124
+ -> Bitmap Heap Scan on atsts
125
+ Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
126
+ -> Bitmap Index Scan on atsts_idx
127
+ Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
128
+ (5 rows)
128
129
129
130
SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
130
131
count
@@ -164,12 +165,14 @@ SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
164
165
165
166
EXPLAIN (costs off)
166
167
SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
167
- QUERY PLAN
168
- -------------------------------------------------------------------------------
168
+ QUERY PLAN
169
+ -----------------------------------------------------------------------------------------
169
170
Aggregate
170
- -> Seq Scan on atsts
171
- Filter: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
172
- (3 rows)
171
+ -> Bitmap Heap Scan on atsts
172
+ Recheck Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
173
+ -> Bitmap Index Scan on atsts_idx
174
+ Index Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
175
+ (5 rows)
173
176
174
177
SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
175
178
count
@@ -179,12 +182,14 @@ SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
179
182
180
183
EXPLAIN (costs off)
181
184
SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
182
- QUERY PLAN
183
- -------------------------------------------------------------------------------
185
+ QUERY PLAN
186
+ -----------------------------------------------------------------------------------------
184
187
Aggregate
185
- -> Seq Scan on atsts
186
- Filter: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
187
- (3 rows)
188
+ -> Bitmap Heap Scan on atsts
189
+ Recheck Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
190
+ -> Bitmap Index Scan on atsts_idx
191
+ Index Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
192
+ (5 rows)
188
193
189
194
SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
190
195
count
@@ -194,95 +199,59 @@ SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
194
199
195
200
EXPLAIN (costs off)
196
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;
197
- QUERY PLAN
198
- -------------------------------------------------------------------------------------
202
+ QUERY PLAN
203
+ -----------------------------------------------------------------------------------
199
204
Limit
200
- -> Sort
201
- Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
202
- -> Seq Scan on atsts
203
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
204
- (5 rows)
205
+ -> Index Scan using atsts_idx on atsts
206
+ Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
207
+ Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
208
+ (4 rows)
205
209
206
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;
207
- id | d | ?column?
208
- -----+---------------------------------+---------------
209
- 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
210
- 354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
211
- 371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
212
- 406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
213
- 415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
214
- (5 rows)
215
-
211
+ ERROR: doesn't support order by over pass-by-reference column
216
212
EXPLAIN (costs off)
217
213
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;
218
- QUERY PLAN
219
- -------------------------------------------------------------------------------------
214
+ QUERY PLAN
215
+ -----------------------------------------------------------------------------------
220
216
Limit
221
- -> Sort
222
- Sort Key: ((d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone))
223
- -> Seq Scan on atsts
224
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
225
- (5 rows)
217
+ -> Index Scan using atsts_idx on atsts
218
+ Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
219
+ Order By: (d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone)
220
+ (4 rows)
226
221
227
222
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;
228
- id | d | ?column?
229
- -----+---------------------------------+---------------
230
- 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
231
- 354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
232
- 252 | Thu May 12 07:21:22.326724 2016 | 370802.673276
233
- 232 | Wed May 11 11:21:22.326724 2016 | 442802.673276
234
- 168 | Sun May 08 19:21:22.326724 2016 | 673202.673276
235
- (5 rows)
236
-
223
+ ERROR: doesn't support order by over pass-by-reference column
237
224
EXPLAIN (costs off)
238
225
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;
239
- QUERY PLAN
240
- -------------------------------------------------------------------------------------
226
+ QUERY PLAN
227
+ -----------------------------------------------------------------------------------
241
228
Limit
242
- -> Sort
243
- Sort Key: ((d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
244
- -> Seq Scan on atsts
245
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
246
- (5 rows)
229
+ -> Index Scan using atsts_idx on atsts
230
+ Index Cond: (t @@ '''wr'' & ''qh'''::tsquery)
231
+ Order By: (d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
232
+ (4 rows)
247
233
248
234
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;
249
- id | d | ?column?
250
- -----+---------------------------------+---------------
251
- 371 | Tue May 17 06:21:22.326724 2016 | 57597.326724
252
- 406 | Wed May 18 17:21:22.326724 2016 | 183597.326724
253
- 415 | Thu May 19 02:21:22.326724 2016 | 215997.326724
254
- 428 | Thu May 19 15:21:22.326724 2016 | 262797.326724
255
- 457 | Fri May 20 20:21:22.326724 2016 | 367197.326724
256
- (5 rows)
257
-
235
+ ERROR: doesn't support order by over pass-by-reference column
258
236
EXPLAIN (costs off)
259
237
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
260
- QUERY PLAN
261
- -------------------------------------------------------------------------------------
238
+ QUERY PLAN
239
+ -----------------------------------------------------------------------------------
262
240
Limit
263
- -> Sort
264
- Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
265
- -> Seq Scan on atsts
266
- (4 rows)
241
+ -> Index Scan using atsts_idx on atsts
242
+ Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
243
+ (3 rows)
267
244
268
245
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atsts ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
269
- id | d | ?column?
270
- -----+---------------------------------+-------------
271
- 355 | Mon May 16 14:21:22.326724 2016 | 2.673276
272
- 356 | Mon May 16 15:21:22.326724 2016 | 3597.326724
273
- 354 | Mon May 16 13:21:22.326724 2016 | 3602.673276
274
- 357 | Mon May 16 16:21:22.326724 2016 | 7197.326724
275
- 353 | Mon May 16 12:21:22.326724 2016 | 7202.673276
276
- (5 rows)
277
-
246
+ ERROR: doesn't support order by over pass-by-reference column
278
247
EXPLAIN (costs off)
279
248
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
280
- QUERY PLAN
281
- ------------------------------------------------------------------------------------------------------------------------
249
+ QUERY PLAN
250
+ ----------------------------------------------------------------------------------------------------------------------------
282
251
Sort
283
252
Sort Key: d
284
- -> Seq Scan on atsts
285
- Filter : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
253
+ -> Index Scan using atsts_idx on atsts
254
+ Index Cond : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
286
255
(4 rows)
287
256
288
257
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
@@ -301,12 +270,12 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER
301
270
302
271
EXPLAIN (costs off)
303
272
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
304
- QUERY PLAN
305
- ------------------------------------------------------------------------------------------------------------------------
273
+ QUERY PLAN
274
+ ----------------------------------------------------------------------------------------------------------------------------
306
275
Sort
307
276
Sort Key: d
308
- -> Seq Scan on atsts
309
- Filter : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
277
+ -> Index Scan using atsts_idx on atsts
278
+ Index Cond : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
310
279
(4 rows)
311
280
312
281
SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
@@ -322,4 +291,3 @@ SELECT id, d FROM atsts WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER
322
291
496 | Sun May 22 11:21:22.326724 2016
323
292
(8 rows)
324
293
325
- DROP TABLE atsts CASCADE;
0 commit comments