11CREATE TABLE atstsh (id int, t tsvector, d timestamp);
22\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)
44 WITH (attach = 'd', to = 't', order_by_attach='t');
5- ERROR: currently, RUM doesn't support order by over pass-by-reference column
65INSERT INTO atstsh VALUES (-1, 't1 t2', '2016-05-02 02:24:22.326724');
76INSERT INTO atstsh VALUES (-2, 't1 t2 t3', '2016-05-02 02:26:22.326724');
87SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
@@ -119,12 +118,14 @@ RESET enable_bitmapscan;
119118SET enable_seqscan = off;
120119EXPLAIN (costs off)
121120SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
122- QUERY PLAN
123- ---------------------------------------------------
121+ QUERY PLAN
122+ -------------------------------------------------------------
124123 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)
128129
129130SELECT count(*) FROM atstsh WHERE t @@ 'wr|qh';
130131 count
@@ -164,12 +165,14 @@ SELECT count(*) FROM atstsh WHERE t @@ '(eq|yt)&(wr|qh)';
164165
165166EXPLAIN (costs off)
166167SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
167- QUERY PLAN
168- -------------------------------------------------------------------------------
168+ QUERY PLAN
169+ -----------------------------------------------------------------------------------------
169170 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)
173176
174177SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
175178 count
@@ -179,12 +182,14 @@ SELECT count(*) FROM atstsh WHERE d < '2016-05-16 14:21:25';
179182
180183EXPLAIN (costs off)
181184SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
182- QUERY PLAN
183- -------------------------------------------------------------------------------
185+ QUERY PLAN
186+ -----------------------------------------------------------------------------------------
184187 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)
188193
189194SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
190195 count
@@ -194,63 +199,59 @@ SELECT count(*) FROM atstsh WHERE d > '2016-05-16 14:21:25';
194199
195200EXPLAIN (costs off)
196201SELECT 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+ -----------------------------------------------------------------------------------
199204 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)
205209
206210SELECT 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;
207211ERROR: doesn't support order by over pass-by-reference column
208212EXPLAIN (costs off)
209213SELECT 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+ -----------------------------------------------------------------------------------
212216 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)
218221
219222SELECT 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;
220223ERROR: doesn't support order by over pass-by-reference column
221224EXPLAIN (costs off)
222225SELECT 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+ -----------------------------------------------------------------------------------
225228 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)
231233
232234SELECT 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;
233235ERROR: doesn't support order by over pass-by-reference column
234236EXPLAIN (costs off)
235237SELECT 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+ -----------------------------------------------------------------------------------
238240 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)
243244
244245SELECT id, d, d <=> '2016-05-16 14:21:25' FROM atstsh ORDER BY d <=> '2016-05-16 14:21:25' LIMIT 5;
245246ERROR: doesn't support order by over pass-by-reference column
246247EXPLAIN (costs off)
247248SELECT 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+ ----------------------------------------------------------------------------------------------------------------------------
250251 Sort
251252 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))
254255(4 rows)
255256
256257SELECT 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
269270
270271EXPLAIN (costs off)
271272SELECT 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+ ----------------------------------------------------------------------------------------------------------------------------
274275 Sort
275276 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))
278279(4 rows)
279280
280281SELECT id, d FROM atstsh WHERE t @@ 'wr&qh' AND d >= '2016-05-16 14:21:25' ORDER BY d;
0 commit comments