Skip to content

Commit 9f78bdc

Browse files
committed
Force for rum.sql and rum_hash.sql queries without ORDER BY to use bitmap scan
1 parent c5be71b commit 9f78bdc

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

expected/rum.out

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
88
CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_addon_ops);
99
ERROR: additional information attribute "a" is not found in index
1010
SET enable_seqscan=off;
11+
SET enable_indexscan=off;
1112
explain (costs off)
1213
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
1314
QUERY PLAN
@@ -35,12 +36,14 @@ ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
3536
explain (costs off)
3637
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english',
3738
'def <-> fgr');
38-
QUERY PLAN
39-
-----------------------------------------------------------
39+
QUERY PLAN
40+
-----------------------------------------------------------------
4041
Aggregate
41-
-> Index Scan using rumidx on test_rum
42-
Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
43-
(3 rows)
42+
-> Bitmap Heap Scan on test_rum
43+
Recheck Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
44+
-> Bitmap Index Scan on rumidx
45+
Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
46+
(5 rows)
4447

4548
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
4649
count
@@ -288,6 +291,7 @@ DELETE FROM tst WHERE i = 5;
288291
VACUUM tst;
289292
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
290293
set enable_bitmapscan=off;
294+
SET enable_indexscan=on;
291295
explain (costs off)
292296
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
293297
FROM test_rum

expected/rum_hash.out

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CREATE INDEX rumhashidx ON test_rum_hash USING rum (a rum_tsvector_hash_ops);
77
CREATE INDEX failed_rumidx ON test_rum_hash USING rum (a rum_tsvector_addon_ops);
88
ERROR: additional information attribute "a" is not found in index
99
SET enable_seqscan=off;
10+
SET enable_indexscan=off;
1011
explain (costs off)
1112
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
1213
QUERY PLAN
@@ -34,12 +35,14 @@ ORDER BY a <=> to_tsquery('pg_catalog.english', 'ever|wrote');
3435
explain (costs off)
3536
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english',
3637
'def <-> fgr');
37-
QUERY PLAN
38-
-----------------------------------------------------------
38+
QUERY PLAN
39+
-----------------------------------------------------------------
3940
Aggregate
40-
-> Index Scan using rumhashidx on test_rum_hash
41-
Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
42-
(3 rows)
41+
-> Bitmap Heap Scan on test_rum_hash
42+
Recheck Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
43+
-> Bitmap Index Scan on rumhashidx
44+
Index Cond: (a @@ '''def'' <-> ''fgr'''::tsquery)
45+
(5 rows)
4346

4447
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
4548
count
@@ -287,6 +290,7 @@ DELETE FROM tst_hash WHERE i = 5;
287290
VACUUM tst_hash;
288291
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
289292
set enable_bitmapscan=off;
293+
SET enable_indexscan=on;
290294
explain (costs off)
291295
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
292296
FROM test_rum_hash

sql/rum.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CREATE INDEX rumidx ON test_rum USING rum (a rum_tsvector_ops);
1212
CREATE INDEX failed_rumidx ON test_rum USING rum (a rum_tsvector_addon_ops);
1313

1414
SET enable_seqscan=off;
15+
SET enable_indexscan=off;
1516

1617
explain (costs off)
1718
SELECT count(*) FROM test_rum WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
@@ -101,6 +102,7 @@ VACUUM tst;
101102
INSERT INTO tst SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
102103

103104
set enable_bitmapscan=off;
105+
SET enable_indexscan=on;
104106
explain (costs off)
105107
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
106108
FROM test_rum

sql/rum_hash.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CREATE INDEX rumhashidx ON test_rum_hash USING rum (a rum_tsvector_hash_ops);
1010
CREATE INDEX failed_rumidx ON test_rum_hash USING rum (a rum_tsvector_addon_ops);
1111

1212
SET enable_seqscan=off;
13+
SET enable_indexscan=off;
1314

1415
explain (costs off)
1516
SELECT count(*) FROM test_rum_hash WHERE a @@ to_tsquery('pg_catalog.english', 'ever|wrote');
@@ -99,6 +100,7 @@ VACUUM tst_hash;
99100
INSERT INTO tst_hash SELECT i%10, to_tsvector('simple', substr(md5(i::text), 1, 1)) FROM generate_series(14001,15000) i;
100101

101102
set enable_bitmapscan=off;
103+
SET enable_indexscan=on;
102104
explain (costs off)
103105
SELECT a <=> to_tsquery('pg_catalog.english', 'w:*'), *
104106
FROM test_rum_hash

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy