ddnexus / pagy

🏆 The Best Pagination Ruby Gem 🥇
https://ddnexus.github.io/pagy
MIT License
4.57k stars 408 forks source link

Keyset pagination #106

Closed espen closed 5 years ago

espen commented 5 years ago

Have you considered keyset pagination? It would result in much better database performance.

I see there is order_query but I haven't tried it. Looking briefly at the code it would definitively complicate things. Perhaps it could be used as a plugin?

What are your thoughts on this?

ddnexus commented 5 years ago

Someone posted a link at the very beginning of the Pagy life about the subject. It sounds interesting but I didn't have the time to really think about it yet. I will add some comment ASAP. Thanks for the interest.

ddnexus commented 5 years ago

it looks like implementing the keyset pagination in Pagy boils down to change just one line of code: https://github.com/ddnexus/pagy/blob/538cf4a5c6e4a031bbd7dab1dfebcd0d591a1ec3/lib/pagy/backend.rb#L28

That could be easy implemented as a backend extra with probably one single method override in it.

If you want to get a shot at it, you will have all my support, because having a keyset extra would be very cool!

espen commented 5 years ago

I guess what is needed is an attribute for which column to use as a key to order. With an input for last seen value to be used when querying the next page. That sounds simple enough but looking at the order_query source I'm not so sure. I will try it out and see if it can be handled directly in pagy or whether it must be more versatile and relay it to order_query as an extra in pagy.

ddnexus commented 5 years ago

Thanks!

ddnexus commented 5 years ago

see #136

ddnexus commented 1 month ago

Long time since this one.

The Pagy::Keyset pagination arrived in all its glory in v9.

Yeah... long time... I know 😁