Mongoid is slow and shows this in the log: MONGODB cursor.refresh() for cursor 3474711247518436755
Asked Answered
F

1

0

I am using admin_assistant and have hacked on MongoDB support. The only issue now is that the index page queries are incredibly slow. admin_assistant uses will_paginate for these queries. I verified that the exact slow-down spot is where the will paginate collection is first accessed (.empty?). In the log I see the query, and after that I see these being slowly printed:

MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755
MONGODB cursor.refresh() for cursor 3474711247518436755

I will probably try getting rid of will_paginate next, but the rest of the code is depending on it right now. Any ideas on what could cause the cursor refreshes?

Floriculture answered 7/9, 2011 at 19:46 Comment(5)
You will see this message when there are too many results being fetched from mongodb. By default mongodb will close the cursor after 2 minutes, if client still doesn't fetches all the data in that time. My guess is the query generated is ultimately a mongoid criteria object and it do not has empty? method, so calling empty? on it triggers fetching results and yielding array of docs. You should post it to will_paginate or mongoid list and meanwhile hack criteria#empty? to test criteria#count(true) == 0Phosphocreatine
When I got rid of .empty? I saw the same behavior form .each. I am seeing this on every request, and it takes about 3 seconds. I will try Mongoid mail list.Floriculture
each will have the same behavior as empty? if my guess is correct, you should try count to see if it also leads to same situation(it shouldn't).Phosphocreatine
Neither will_paginate nor admin_assistant (as it seems) support MongoDB out of the box. I don't see what the big surprise is here. Somewhere, mongo pagination was performed in an unoptimized way. But, no point in investigated further if Kaminari works for you.Unific
I've been having this issue as well; is there a way to make will_paginate support MongoDB with reasonable performance?Vassalage
F
0

Thanks for your comments, rubish!

I switched from will_paginate to kaminari and everything works now.

Floriculture answered 8/9, 2011 at 19:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.