Open cheerfulstoic opened 9 years ago
Could there be a situation where a valid query uses skip
twice, maybe with a with
somewhere in the middle? If so, you'd need to be careful that it doesn't reuse the parameter.
Yeah, I expect that there would be ;) So this might need to be an indexed thing (skip_0
, skip_1
, etc...)
I switched pagination from Kaminari to will_paginate. No significant difference in response time. The first fetch of 20 authors takes 17 seconds or so. I used the database for a while to have the caches warmed up. Total number of authors: 4.1 millions. Both properties uuid and author_name are uniquely indexed.
Started GET "/authors" for 127.0.0.1 at 2015-08-20 10:30:28 -0400
Processing by AuthorsController#index as HTML
CYPHER 6780ms MATCH (result_author:`Author`) RETURN count(result_author) AS result_author
CYPHER 9946ms MATCH (result_author:`Author`) RETURN result_author ORDER BY result_author.author_name SKIP {skip_0} LIMIT {limit_20} | {:skip_0=>0, :limit_20=>20}
Rendered home/_main_links.html.erb (0.3ms)
Rendered authors/index.html.erb within layouts/application (5.3ms)
Completed 200 OK in 17100ms (Views: 370.4ms)
Yeah, I've had problems with pagination myself in my database which has 8 million rows for a label. It comes down to Neo4j, I think. I don't know if there's a way to solve this from the gem. @jexp seemed to have some thoughts on why there might be a way to improve. Also there are hopefully some changes coming down the pipeline (don't know when) to improve this
The first cypher query about the count takes 6.6 seconds to be executed by the database. Maybe an improvement here is to do the count using the unique index created on UUID. I am not an expert here, I am thinking based on my previous experience with relational databases where a statement like this: select count(1) from
If you have pagination of 50 then the parameter shouldn't be
skip_50
because the query doesn't get cached