-
Notifications
You must be signed in to change notification settings - Fork 114
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
Feature Request: Cursor-based Pagination #270
Comments
@rs can help me on this? Edge beta release will be greatly appreciated. I might be naive but it should be a simple feature in my opinion. Otherwise, can you suggest me how to work around with cursor base pagination with |
For now I was thinking the cursor based pagination can be achieved with filter greater than or lesser than. However this means the client is forced to be aware on this pagination logic. It can be okay-ish if the design from beginning is to allow client / consumer to moderate pagination by specifying the filtering field + limit. But we have been following the strategy for pagination in Slack API Pagination such that if the fields used for this cursor changed in the Backend logic, Frontend or client doesn't need to care with the API changes. The result, yes might be different but the interface is still same. |
Just to give a solution you can use today; you can use:
This can be implemented in client logic without any rest-layer changes. You can of course also combine the id filter with your own filter, e.g. using an outer This require the PS! Iterating/sorting on other fields this way is possible, but require that the field is sortable, filterable AND unique (for the given filter). |
I wonder if we can support cursor-based pagination instead of offset based.
I was hoping to get something like: Slack API Pagination
We are hoping to get a RESTful feature for this cursor-based because our micro services have been using cursor for fast lookup. It saves time not to scan though
n
records in database that we don't retrieve wheren
is the number of offset. I think this benefit greatly for speed. The database that use some sort of sorted table, merge tree, or B+tree can benefit greatly because cursor translate to a where clauseindex >= <YOUR VALUE>
which can skip data partitions where condition is not met, pruning a lot of scanning. Where as N offset means the database have to count from 0 - offset before retrieving items, wasting time on scanning N items.I propose that:
resource.ItemList
has 1 more field calledCursor string
.Cursor
is optional. If suppose the request includes?cursor="<base64 or whatever string encoded>"
then the storer can respect this condition and fetch the database for a given cursor.NOTE:
Cursor string
can translate to multi fields in database, let sayBase64Encoded(CreatedAt, UpdatedAt)
. This means filter out item that areCreatedAt < cursorCreatedAt
andUpdatedAt < cursorUpdatedAt
The text was updated successfully, but these errors were encountered: