Skip to content

Feature Request: Cursor-based Pagination  #270

Open
@danielkurniadi

Description

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 where n 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 clause index >= <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:

  1. resource.ItemList has 1 more field called Cursor string.
  2. 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 say Base64Encoded(CreatedAt, UpdatedAt). This means filter out item that are CreatedAt < cursorCreatedAt and UpdatedAt < cursorUpdatedAt

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions