1
1
CREATE TABLE atstsh (id int, t tsvector, d timestamp);
2
2
\copy atstsh from 'data/tsts.data'
3
- CREATE INDEX atstsh_idx ON atstsh USING rum (t rum_tsvector_hash_timestamp_ops , d)
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
- ERROR: currently, RUM doesn't support order by over pass-by-reference column
6
5
INSERT INTO atstsh VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
7
6
INSERT INTO atstsh VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
8
7
SELECT count(*) FROM atstsh 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 atstsh WHERE t @@ 'wr|qh';
122
- QUERY PLAN
123
- ---------------------------------------------------
121
+ QUERY PLAN
122
+ -------------------------------------------------------------
124
123
Aggregate
125
- -> Seq Scan on atstsh
126
- Filter: (t @@ '''wr'' | ''qh'''::tsquery)
127
- (3 rows)
124
+ -> Bitmap Heap Scan on atstsh
125
+ Recheck Cond: (t @@ '''wr'' | ''qh'''::tsquery)
126
+ -> Bitmap Index Scan on atstsh_idx
127
+ Index Cond: (t @@ '''wr'' | ''qh'''::tsquery)
128
+ (5 rows)
128
129
129
130
SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
130
131
count
@@ -164,12 +165,14 @@ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
164
165
165
166
EXPLAIN (costs off)
166
167
SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
167
- QUERY PLAN
168
- -------------------------------------------------------------------------------
168
+ QUERY PLAN
169
+ -----------------------------------------------------------------------------------------
169
170
Aggregate
170
- -> Seq Scan on atstsh
171
- Filter: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
172
- (3 rows)
171
+ -> Bitmap Heap Scan on atstsh
172
+ Recheck Cond: (d < 'Mon May 16 14:21:25 2016'::timestamp without time zone)
173
+ -> Bitmap Index Scan on atstsh_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 atstsh WHERE d < '2016-05-16 14:21:25';
175
178
count
@@ -179,12 +182,14 @@ SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
179
182
180
183
EXPLAIN (costs off)
181
184
SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
182
- QUERY PLAN
183
- -------------------------------------------------------------------------------
185
+ QUERY PLAN
186
+ -----------------------------------------------------------------------------------------
184
187
Aggregate
185
- -> Seq Scan on atstsh
186
- Filter: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
187
- (3 rows)
188
+ -> Bitmap Heap Scan on atstsh
189
+ Recheck Cond: (d > 'Mon May 16 14:21:25 2016'::timestamp without time zone)
190
+ -> Bitmap Index Scan on atstsh_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 atstsh WHERE d > '2016-05-16 14:21:25';
190
195
count
@@ -194,63 +199,59 @@ SELECT count(*) FROM atstsh 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 atstsh 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 atstsh
203
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
204
- (5 rows)
205
+ -> Index Scan using atstsh_idx on atstsh
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 atstsh WHERE t @@ 'wr&qh' ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
207
211
ERROR: doesn't support order by over pass-by-reference column
208
212
EXPLAIN (costs off)
209
213
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;
210
- QUERY PLAN
211
- -------------------------------------------------------------------------------------
214
+ QUERY PLAN
215
+ -----------------------------------------------------------------------------------
212
216
Limit
213
- -> Sort
214
- Sort Key: ((d <=| 'Mon May 16 14:21:25 2016'::timestamp without time zone))
215
- -> Seq Scan on atstsh
216
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
217
- (5 rows)
217
+ -> Index Scan using atstsh_idx on atstsh
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)
218
221
219
222
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;
220
223
ERROR: doesn't support order by over pass-by-reference column
221
224
EXPLAIN (costs off)
222
225
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;
223
- QUERY PLAN
224
- -------------------------------------------------------------------------------------
226
+ QUERY PLAN
227
+ -----------------------------------------------------------------------------------
225
228
Limit
226
- -> Sort
227
- Sort Key: ((d |=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
228
- -> Seq Scan on atstsh
229
- Filter: (t @@ '''wr'' & ''qh'''::tsquery)
230
- (5 rows)
229
+ -> Index Scan using atstsh_idx on atstsh
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)
231
233
232
234
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;
233
235
ERROR: doesn't support order by over pass-by-reference column
234
236
EXPLAIN (costs off)
235
237
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
236
- QUERY PLAN
237
- -------------------------------------------------------------------------------------
238
+ QUERY PLAN
239
+ -----------------------------------------------------------------------------------
238
240
Limit
239
- -> Sort
240
- Sort Key: ((d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone))
241
- -> Seq Scan on atstsh
242
- (4 rows)
241
+ -> Index Scan using atstsh_idx on atstsh
242
+ Order By: (d <=> 'Mon May 16 14:21:25 2016'::timestamp without time zone)
243
+ (3 rows)
243
244
244
245
SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
245
246
ERROR: doesn't support order by over pass-by-reference column
246
247
EXPLAIN (costs off)
247
248
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
248
- QUERY PLAN
249
- ------------------------------------------------------------------------------------------------------------------------
249
+ QUERY PLAN
250
+ ----------------------------------------------------------------------------------------------------------------------------
250
251
Sort
251
252
Sort Key: d
252
- -> Seq Scan on atstsh
253
- Filter : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
253
+ -> Index Scan using atstsh_idx on atstsh
254
+ Index Cond : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d <= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
254
255
(4 rows)
255
256
256
257
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDER BY d;
@@ -269,12 +270,12 @@ SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d <= '2016-05-16 14:21:25' ORDE
269
270
270
271
EXPLAIN (costs off)
271
272
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
272
- QUERY PLAN
273
- ------------------------------------------------------------------------------------------------------------------------
273
+ QUERY PLAN
274
+ ----------------------------------------------------------------------------------------------------------------------------
274
275
Sort
275
276
Sort Key: d
276
- -> Seq Scan on atstsh
277
- Filter : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
277
+ -> Index Scan using atstsh_idx on atstsh
278
+ Index Cond : ((t @@ '''wr'' & ''qh'''::tsquery) AND (d >= 'Mon May 16 14:21:25 2016'::timestamp without time zone))
278
279
(4 rows)
279
280
280
281
SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
0 commit comments