Using Rails 7.1 async_count #561
Replies: 3 comments 2 replies
-
Thank you for your suggestion. I would need to look at the PR before making commenting with intelligence. However, at first glance, I can see no objection to it (apart from dealing with backwards compatibility)? I will have to return to this issue. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I forgot to comment on this one. The main concern is that pagy tries to be agnostic, so no rails code should be used in the gem code. The From what you say it looks like the introduction of the In other words, it would be safer as an opt-in overriding, rather than as an opt-out default feature. |
Beta Was this translation helpful? Give feedback.
-
FYI - if you want to override, consider the ideas below: https://ddnexus.github.io/pagy/docs/how-to/#override-pagy-methods Feel free to re-open if I've missed the mark, or you have further info to add. |
Beta Was this translation helpful? Give feedback.
-
Using
pagy(collection)
with ActiveRecord will trigger a COUNT-query. With Rails 7.1, a new.async_count
method was added, which can be used instead of.count
. I was wondering if this could be used here:pagy/lib/pagy/extras/arel.rb
Lines 24 to 27 in 836fb75
The counting will only be performed asynchronous if the application is configured to use async database queries, otherwise nothing should change.
Beta Was this translation helpful? Give feedback.
All reactions