1- CREATE TABLE test_rum ( t text, a tsvector );
1+ CREATE TABLE test_rum_hash ( t text, a tsvector );
22CREATE TRIGGER tsvectorupdate
3- BEFORE UPDATE OR INSERT ON test_rum
3+ BEFORE UPDATE OR INSERT ON test_rum_hash
44FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('a', 'pg_catalog.english', 't');
5- CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_hash_ops);
6- \copy test_rum (t) from 'data/rum.data';
7- CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_addon_ops);
5+ CREATE INDEX rumhashidx ON test_rum_hash USING rum (a rum_tsvector_hash_ops);
6+ \copy test_rum_hash (t) from 'data/rum.data';
7+ CREATE INDEX failed_rumidx ON test_rum_hash USING rum (a rum_tsvector_addon_ops);
88ERROR: additional information attribute "a" is not found in index
99SET enable_seqscan=off;
1010explain (costs off)
11- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
11+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
1212 QUERY PLAN
1313------------------------------------------------------------------
1414 Aggregate
15- -> Bitmap Heap Scan on test_rum
15+ -> Bitmap Heap Scan on test_rum_hash
1616 Recheck Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
17- -> Bitmap Index Scan on rumidx
17+ -> Bitmap Index Scan on rumhashidx
1818 Index Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
1919(5 rows)
2020
2121explain (costs off)
22- SELECT * FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote')
22+ SELECT * FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote')
2323ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
2424 QUERY PLAN
2525------------------------------------------------------------------
2626 Sort
2727 Sort Key: ((a <=> '''ever'' | ''wrote'''::tsquery))
28- -> Bitmap Heap Scan on test_rum
28+ -> Bitmap Heap Scan on test_rum_hash
2929 Recheck Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
30- -> Bitmap Index Scan on rumidx
30+ -> Bitmap Index Scan on rumhashidx
3131 Index Cond: (a @@ '''ever'' | ''wrote'''::tsquery)
3232(6 rows)
3333
3434explain (costs off)
35- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
35+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
3636 'def <-> fgr');
3737 QUERY PLAN
3838-----------------------------------------------------------
3939 Aggregate
40- -> Index Scan using rumidx on test_rum
40+ -> Index Scan using rumhashidx on test_rum_hash
4141 Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
4242(3 rows)
4343
44- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
44+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
4545 count
4646-------
4747 2
4848(1 row)
4949
50- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'have&wish');
50+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'have&wish');
5151 count
5252-------
5353 1
5454(1 row)
5555
56- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'knew&brain');
56+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'knew&brain');
5757 count
5858-------
5959 0
6060(1 row)
6161
62- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'among');
62+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'among');
6363 count
6464-------
6565 1
6666(1 row)
6767
68- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'structure&ancient');
68+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'structure&ancient');
6969 count
7070-------
7171 1
7272(1 row)
7373
74- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(complimentary|sight)&(sending|heart)');
74+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(complimentary|sight)&(sending|heart)');
7575 count
7676-------
7777 2
7878(1 row)
7979
80- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | half) <-> way');
80+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(gave | half) <-> way');
8181 count
8282-------
8383 2
8484(1 row)
8585
86- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '(gave | !half) <-> way');
86+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '(gave | !half) <-> way');
8787 count
8888-------
8989 3
9090(1 row)
9191
92- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & way');
92+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '!gave & way');
9393 count
9494-------
9595 3
9696(1 row)
9797
98- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '!gave & wooded & !look');
98+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '!gave & wooded & !look');
9999 count
100100-------
101101 1
102102(1 row)
103103
104- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
104+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
105105 'def <-> fgr');
106106 count
107107-------
108108 1
109109(1 row)
110110
111- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
111+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
112112 'def <2> fgr');
113113 count
114114-------
115115 1
116116(1 row)
117117
118118SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
119- FROM test_rum
119+ FROM test_rum_hash
120120 WHERE a @@ to_tsquery('pg_catalog.english', 'way')
121121 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
122122 rum_ts_distance | t | a
@@ -128,7 +128,7 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way')), *
128128(4 rows)
129129
130130SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')), *
131- FROM test_rum
131+ FROM test_rum_hash
132132 WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
133133 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
134134 rum_ts_distance | t | a
@@ -141,7 +141,7 @@ SELECT
141141 a <=> to_tsquery('pg_catalog.english', 'way & (go | half)'),
142142 rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way & (go | half)')),
143143 *
144- FROM test_rum
144+ FROM test_rum_hash
145145 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)') limit 2;
146146 ?column? | rum_ts_distance | t | a
147147----------+-----------------+---------------------------------------------------------------------+---------------------------------------------------------
@@ -151,7 +151,7 @@ SELECT
151151
152152-- Check ranking normalization
153153SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
154- FROM test_rum
154+ FROM test_rum_hash
155155 WHERE a @@ to_tsquery('pg_catalog.english', 'way')
156156 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way');
157157 rum_ts_distance | t | a
@@ -163,7 +163,7 @@ SELECT rum_ts_distance(a, to_tsquery('pg_catalog.english', 'way'), 0), *
163163(4 rows)
164164
165165SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half)'), 0)::rum_distance_query), *
166- FROM test_rum
166+ FROM test_rum_hash
167167 WHERE a @@ to_tsquery('pg_catalog.english', 'way & (go | half)')
168168 ORDER BY a <=> to_tsquery('pg_catalog.english', 'way & (go | half)');
169169 rum_ts_distance | t | a
@@ -172,42 +172,42 @@ SELECT rum_ts_distance(a, row(to_tsquery('pg_catalog.english', 'way & (go | half
172172 57.5727 | thinking--"to go or not to go?" We are this far on the way. Reached | 'far':11 'go':3,7 'reach':15 'think':1 'way':14
173173(2 rows)
174174
175- INSERT INTO test_rum (t) VALUES ('foo bar foo the over foo qq bar');
176- INSERT INTO test_rum (t) VALUES ('345 qwerty copyright');
177- INSERT INTO test_rum (t) VALUES ('345 qwerty');
178- INSERT INTO test_rum (t) VALUES ('A fat cat has just eaten a rat.');
179- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar');
175+ INSERT INTO test_rum_hash (t) VALUES ('foo bar foo the over foo qq bar');
176+ INSERT INTO test_rum_hash (t) VALUES ('345 qwerty copyright');
177+ INSERT INTO test_rum_hash (t) VALUES ('345 qwerty');
178+ INSERT INTO test_rum_hash (t) VALUES ('A fat cat has just eaten a rat.');
179+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'bar');
180180 count
181181-------
182182 1
183183(1 row)
184184
185- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'qwerty&345');
185+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'qwerty&345');
186186 count
187187-------
188188 2
189189(1 row)
190190
191- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', '345');
191+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', '345');
192192 count
193193-------
194194 2
195195(1 row)
196196
197- SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'rat');
197+ SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'rat');
198198 count
199199-------
200200 1
201201(1 row)
202202
203- SELECT a FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER BY a;
203+ SELECT a FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'bar') ORDER BY a;
204204 a
205205------------------------------
206206 'bar':2,8 'foo':1,3,6 'qq':7
207207(1 row)
208208
209209-- Check full-index scan with order by
210- SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
210+ SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum_hash ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
211211 ?column?
212212----------
213213 16.4493
@@ -268,41 +268,39 @@ SELECT a <=> to_tsquery('pg_catalog.english', 'ever|wrote') FROM test_rum ORDER
268268 Infinity
269269(56 rows)
270270
271- CREATE TABLE tst (i int4, t tsvector);
272- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
273- CREATE INDEX tstidx ON tst USING rum (t rum_tsvector_hash_ops);
274- DELETE FROM tst WHERE i = 1;
275- VACUUM tst ;
276- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(10001,11000) i;
277- DELETE FROM tst WHERE i = 2;
278- VACUUM tst ;
279- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(11001,12000) i;
280- DELETE FROM tst WHERE i = 3;
281- VACUUM tst ;
282- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(12001,13000) i;
283- DELETE FROM tst WHERE i = 4;
284- VACUUM tst ;
285- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(13001,14000) i;
286- DELETE FROM tst WHERE i = 5;
287- VACUUM tst ;
288- INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
271+ CREATE TABLE tst_hash (i int4, t tsvector);
272+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(1,100000) i;
273+ CREATE INDEX tst_hashidx ON tst_hash USING rum (t rum_tsvector_hash_ops);
274+ DELETE FROM tst_hash WHERE i = 1;
275+ VACUUM tst_hash ;
276+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(10001,11000) i;
277+ DELETE FROM tst_hash WHERE i = 2;
278+ VACUUM tst_hash ;
279+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(11001,12000) i;
280+ DELETE FROM tst_hash WHERE i = 3;
281+ VACUUM tst_hash ;
282+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(12001,13000) i;
283+ DELETE FROM tst_hash WHERE i = 4;
284+ VACUUM tst_hash ;
285+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(13001,14000) i;
286+ DELETE FROM tst_hash WHERE i = 5;
287+ VACUUM tst_hash ;
288+ INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
289289set enable_bitmapscan=off;
290290explain (costs off)
291291SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
292- FROM test_rum
292+ FROM test_rum_hash
293293 WHERE a @@ to_tsquery('pg_catalog.english', 'w:*')
294294 ORDER BY a <=> to_tsquery('pg_catalog.english', 'w:*');
295- QUERY PLAN
296- -----------------------------------------
297- Index Scan using rumidx on test_rum
295+ QUERY PLAN
296+ ----------------------------------------------
297+ Index Scan using rumhashidx on test_rum_hash
298298 Index Cond: (a @@ '''w'':*'::tsquery)
299299 Order By: (a <=> '''w'':*'::tsquery)
300300(3 rows)
301301
302302SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
303- FROM test_rum
303+ FROM test_rum_hash
304304 WHERE a @@ to_tsquery('pg_catalog.english', 'w:*')
305305 ORDER BY a <=> to_tsquery('pg_catalog.english', 'w:*');
306306ERROR: Compare with prefix expressions isn't supported
307- DROP TABLE test_rum CASCADE;
308- DROP TABLE tst CASCADE;
0 commit comments