@@ -42,3 +42,268 @@ SELECT * FROM test_text WHERE i>'abc' ORDER BY i;
4242 xyz
4343(2 rows)
4444
45+ CREATE TABLE test_text_o AS SELECT id::text, t FROM tsts;
46+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
47+ id
48+ -----
49+ 135
50+ 16
51+ 168
52+ 232
53+ 252
54+ 354
55+ 355
56+ 371
57+ 39
58+ (9 rows)
59+
60+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
61+ id
62+ -----
63+ 406
64+ 415
65+ 428
66+ 457
67+ 458
68+ 484
69+ 496
70+ 71
71+ (8 rows)
72+
73+ CREATE INDEX test_text_o_idx ON test_text_o USING rum
74+ (t rum_tsvector_addon_ops, id)
75+ WITH (attach = 'id', to = 't');
76+ RESET enable_indexscan;
77+ RESET enable_indexonlyscan;
78+ SET enable_bitmapscan=OFF;
79+ SET enable_seqscan = off;
80+ EXPLAIN (costs off)
81+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
82+ QUERY PLAN
83+ ---------------------------------------------------------------------------------
84+ Sort
85+ Sort Key: id
86+ -> Index Scan using test_text_o_idx on test_text_o
87+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
88+ (4 rows)
89+
90+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
91+ id
92+ -----
93+ 135
94+ 16
95+ 168
96+ 232
97+ 252
98+ 354
99+ 355
100+ 371
101+ 39
102+ (9 rows)
103+
104+ EXPLAIN (costs off)
105+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
106+ QUERY PLAN
107+ ---------------------------------------------------------------------------------
108+ Sort
109+ Sort Key: id
110+ -> Index Scan using test_text_o_idx on test_text_o
111+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
112+ (4 rows)
113+
114+ SELECT id FROM test_text_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
115+ id
116+ -----
117+ 406
118+ 415
119+ 428
120+ 457
121+ 458
122+ 484
123+ 496
124+ 71
125+ (8 rows)
126+
127+ CREATE TABLE test_text_a AS SELECT id::text, t FROM tsts;
128+ CREATE INDEX test_text_a_idx ON test_text_a USING rum
129+ (t rum_tsvector_addon_ops, id)
130+ WITH (attach = 'id', to = 't', order_by_attach='t');
131+ EXPLAIN (costs off)
132+ SELECT count(*) FROM test_text_a WHERE id < '400';
133+ QUERY PLAN
134+ -------------------------------------------------------
135+ Aggregate
136+ -> Index Scan using test_text_a_idx on test_text_a
137+ Index Cond: (id < '400'::text)
138+ (3 rows)
139+
140+ SELECT count(*) FROM test_text_a WHERE id < '400';
141+ count
142+ -------
143+ 337
144+ (1 row)
145+
146+ EXPLAIN (costs off)
147+ SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
148+ QUERY PLAN
149+ ---------------------------------------------------------------------------------
150+ Sort
151+ Sort Key: id
152+ -> Index Scan using test_text_a_idx on test_text_a
153+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
154+ (4 rows)
155+
156+ SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
157+ id
158+ -----
159+ 135
160+ 16
161+ 168
162+ 232
163+ 252
164+ 354
165+ 355
166+ 371
167+ 39
168+ (9 rows)
169+
170+ EXPLAIN (costs off)
171+ SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
172+ QUERY PLAN
173+ ---------------------------------------------------------------------------------
174+ Sort
175+ Sort Key: id
176+ -> Index Scan using test_text_a_idx on test_text_a
177+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
178+ (4 rows)
179+
180+ SELECT id FROM test_text_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
181+ id
182+ -----
183+ 406
184+ 415
185+ 428
186+ 457
187+ 458
188+ 484
189+ 496
190+ 71
191+ (8 rows)
192+
193+ CREATE TABLE test_text_h_o AS SELECT id::text, t FROM tsts;
194+ CREATE INDEX test_text_h_o_idx ON test_text_h_o USING rum
195+ (t rum_tsvector_hash_addon_ops, id)
196+ WITH (attach = 'id', to = 't');
197+ EXPLAIN (costs off)
198+ SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
199+ QUERY PLAN
200+ ---------------------------------------------------------------------------------
201+ Sort
202+ Sort Key: id
203+ -> Index Scan using test_text_h_o_idx on test_text_h_o
204+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
205+ (4 rows)
206+
207+ SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
208+ id
209+ -----
210+ 135
211+ 16
212+ 168
213+ 232
214+ 252
215+ 354
216+ 355
217+ 371
218+ 39
219+ (9 rows)
220+
221+ EXPLAIN (costs off)
222+ SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
223+ QUERY PLAN
224+ ---------------------------------------------------------------------------------
225+ Sort
226+ Sort Key: id
227+ -> Index Scan using test_text_h_o_idx on test_text_h_o
228+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
229+ (4 rows)
230+
231+ SELECT id FROM test_text_h_o WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
232+ id
233+ -----
234+ 406
235+ 415
236+ 428
237+ 457
238+ 458
239+ 484
240+ 496
241+ 71
242+ (8 rows)
243+
244+ CREATE TABLE test_text_h_a AS SELECT id::text, t FROM tsts;
245+ CREATE INDEX test_text_h_a_idx ON test_text_h_a USING rum
246+ (t rum_tsvector_hash_addon_ops, id)
247+ WITH (attach = 'id', to = 't', order_by_attach='t');
248+ EXPLAIN (costs off)
249+ SELECT count(*) FROM test_text_h_a WHERE id < '400';
250+ QUERY PLAN
251+ -----------------------------------------------------------
252+ Aggregate
253+ -> Index Scan using test_text_h_a_idx on test_text_h_a
254+ Index Cond: (id < '400'::text)
255+ (3 rows)
256+
257+ SELECT count(*) FROM test_text_h_a WHERE id < '400';
258+ count
259+ -------
260+ 337
261+ (1 row)
262+
263+ EXPLAIN (costs off)
264+ SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
265+ QUERY PLAN
266+ ---------------------------------------------------------------------------------
267+ Sort
268+ Sort Key: id
269+ -> Index Scan using test_text_h_a_idx on test_text_h_a
270+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id <= '400'::text))
271+ (4 rows)
272+
273+ SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id <= '400' ORDER BY id;
274+ id
275+ -----
276+ 135
277+ 16
278+ 168
279+ 232
280+ 252
281+ 354
282+ 355
283+ 371
284+ 39
285+ (9 rows)
286+
287+ EXPLAIN (costs off)
288+ SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
289+ QUERY PLAN
290+ ---------------------------------------------------------------------------------
291+ Sort
292+ Sort Key: id
293+ -> Index Scan using test_text_h_a_idx on test_text_h_a
294+ Index Cond: ((t @@ '''wr'' & ''qh'''::tsquery) AND (id >= '400'::text))
295+ (4 rows)
296+
297+ SELECT id FROM test_text_h_a WHERE t @@ 'wr&qh' AND id >= '400' ORDER BY id;
298+ id
299+ -----
300+ 406
301+ 415
302+ 428
303+ 457
304+ 458
305+ 484
306+ 496
307+ 71
308+ (8 rows)
309+
0 commit comments