rum
rum copied to clipboard
Speedup DESC queries
From #15. The DESC query slower:
explain analyze select * from rum where tsvector @@ plainto_tsquery('simple', 'cow') order by id <=> 1000000 limit 10;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=3.00..3.53 rows=10 width=56) (actual time=31.367..31.375 rows=10 loops=1)
-> Index Scan using rum_tsvector_id_idx on rum (cost=3.00..2635.10 rows=49960 width=56) (actual time=31.365..31.371 rows=10 loops=1)
Index Cond: (tsvector @@ '''cow'''::tsquery)
Order By: (id <=> 1000000)
Planning time: 0.133 ms
Execution time: 31.427 ms
than the next ASC query:
explain analyze select * from rum where tsvector @@ plainto_tsquery('simple', 'cow') order by id <=> 0 limit 10;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=3.00..3.53 rows=10 width=56) (actual time=18.329..18.338 rows=10 loops=1)
-> Index Scan using rum_tsvector_id_idx on rum (cost=3.00..2635.10 rows=49960 width=56) (actual time=18.328..18.335 rows=10 loops=1)
Index Cond: (tsvector @@ '''cow'''::tsquery)
Order By: (id <=> 0)
Planning time: 0.139 ms
Execution time: 18.393 ms