Skip to content

Speedup DESC queries #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
za-arthur opened this issue Dec 7, 2017 · 0 comments
Closed

Speedup DESC queries #35

za-arthur opened this issue Dec 7, 2017 · 0 comments

Comments

@za-arthur
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants