-
-
Notifications
You must be signed in to change notification settings - Fork 692
Cursor Based Pagination #300
Description
It would be fantastic if SeaORM could support pagination in an efficient manner, namely by using a combination of first/after or last/before count/cursor combinations.
I see that the current implementation uses OFFSET and LIMIT to do pagination, which will work just fine for small tables, but quickly becomes an issue as the size of the table grows. Imagine that an OFFSET grows very large, then this becomes necessarily a lot of work for the database as the entire ordered result set containing OFFSET + LIMIT rows needs to be computed then OFFSET rows skipped over.
This topic has been written about many, many times.
A more efficient way of tackling this problem would be to use a cursor based pagination where the database can leverage its indexes to produce the ordered result set starting from the cursor. e.g. SELECT id, name FROM table WHERE table.id >= $after LIMIT $first;.
This feels like it might be a necessary approach for users wanting to use this ORM at anything resembling scale and would greatly assist implementation for systems that de facto use cursor based pagination (i.e., graphQL).
It's unlikely I'll be able to contribute a PR to implement this unfortunately, but figured I'd raise the issue for anyone else.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status