11CREATE TABLE atsts (id int, t tsvector, d timestamp);
22\copy atsts from 'data/tsts.data'
3- CREATE INDEX atsts_idx ON atsts USING rum (trum_tsvector_timestamp_ops , d)
3+ CREATE INDEX atsts_idx ON atsts USING rum (trum_tsvector_addon_ops , d)
44WITH (attach = 'd', to = 't', order_by_attach='t');
5- ERROR: currently, RUM doesn't support order by over pass-by-reference column
65INSERT INTO atsts VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
76INSERT INTO atsts VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
87SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
@@ -119,12 +118,14 @@ RESET enable_bitmapscan;
119118SET enable_seqscan = off;
120119EXPLAIN (costs off)
121120SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
122- QUERY PLAN
123- ---------------------------------------------------
121+ QUERY PLAN
122+ -------------------------------------------------------------
124123 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)
128129
129130SELECT count(*) FROM atsts WHERE t @@ 'wr|qh';
130131 count
@@ -164,12 +165,14 @@ SELECT count(*) FROM atsts WHERE t @@ '(eq|yt)&(wr|qh)';
164165
165166EXPLAIN (costs off)
166167SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
167- QUERY PLAN
168- -------------------------------------------------------------------------------
168+ QUERY PLAN
169+ -----------------------------------------------------------------------------------------
169170 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)
173176
174177SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
175178 count
@@ -179,12 +182,14 @@ SELECT count(*) FROM atsts WHERE d < '2016-05-16 14:21:25';
179182
180183EXPLAIN (costs off)
181184SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
182- QUERY PLAN
183- -------------------------------------------------------------------------------
185+ QUERY PLAN
186+ -----------------------------------------------------------------------------------------
184187 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)
188193
189194SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
190195 count
@@ -194,95 +199,59 @@ SELECT count(*) FROM atsts WHERE d > '2016-05-16 14:21:25';
194199
195200EXPLAIN (costs off)
196201SELECT 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+ -----------------------------------------------------------------------------------
199204 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)
205209
206210SELECT 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
216212EXPLAIN (costs off)
217213SELECT 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+ -----------------------------------------------------------------------------------
220216 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)
226221
227222SELECT 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
237224EXPLAIN (costs off)
238225SELECT 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+ -----------------------------------------------------------------------------------
241228 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)
247233
248234SELECT 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
258236EXPLAIN (costs off)
259237SELECT 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+ -----------------------------------------------------------------------------------
262240 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)
267244
268245SELECT 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
278247EXPLAIN (costs off)
279248SELECT 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+ ----------------------------------------------------------------------------------------------------------------------------
282251 Sort
283252 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))
286255(4 rows)
287256
288257SELECT 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
301270
302271EXPLAIN (costs off)
303272SELECT 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+ ----------------------------------------------------------------------------------------------------------------------------
306275 Sort
307276 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))
310279(4 rows)
311280
312281SELECT 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
322291 496 | Sun May 22 11:21:22.326724 2016
323292(8 rows)
324293
325- DROP TABLE atsts CASCADE;