Skip to content

Remove total count comparison for next and previous page check #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bc-afeng
Copy link

@bc-afeng bc-afeng commented May 2, 2025

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 #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.

@bc-afeng
Copy link
Author

Hi, @nicolas-fricke any chance you could take a look at this PR? With the current implementation we are essentially mitigating any improvements provided by cursor pagination as we are having to query all items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant