rails_cursor_pagination
rails_cursor_pagination copied to clipboard
Remove total count comparison for next and previous page check
trafficstars
We noticed that even without providing with_total: true, paginator was performing two select count(*) queries in order to determine the next and previous pages. This has also been highlighted as an issue in https://github.com/xing/rails_cursor_pagination/issues/132.
D, [2025-05-01T15:34:32.537527 #37251] DEBUG -- : VaultedInstrument Count (16.6ms) SELECT COUNT(*)
D, [2025-05-01T15:34:32.558816 #37251] DEBUG -- : VaultedInstrument Count (20.5ms) SELECT COUNT(*)
To determine the existence of a next page we should be able to just rely on the existence of a cursor. This PR removes the total count check.
The logic here is that if a cursor has been provided, we must have come from a page that provided us a cursor. This should also significantly speed up deep queries.