-
Notifications
You must be signed in to change notification settings - Fork 28
Improve pagination performance without using OFFSET
#1347
Comments
Note that it's not uncommon to have more than one column for that. Example:
You might be interested in laravel/framework#22446 which added a very low-level statement support which can be used for building this. |
@mfn Thanks for your comment! As you described, endless scrolling/loading doesn't need a And this "endless scrolling/loading" is getting more and more popular nowadays. I think it's worth to get this feature into the framework now. Do you have any better suggestion on this idea? Thanks. |
This is attempted in laravel/framework#37216 |
According to SQL Feature Comparison, SQLServer does not support Tuple Comparison syntax. So (a, b, c) > (1, 2, 3) should be rewritten to a=1 and b=2 and c>3
or
a=1 and b>2
or
a>1 If you use SQLServer, still lampager/lampager-laravel: Rapid pagination for Laravel may help implementing cursor pagination. |
Currently the pagination logic generates
OFFSET LIMIT ?
in the SQL.(see https://github.com/laravel/framework/blob/5.7/src/Illuminate/Database/Eloquent/Builder.php#L746)
which brings a huge performance impact when querying large database.
(See more detail at Faster Pagination in Mysql – Why Order By With Limit and Offset is Slow?)
Please consider to support a cursor based pagination.
We can introduce a new method for cursor based pagination.
The signature of the cursor based pagination would be
What do you think?
If this is OK to have I'll send a PR for this.
The text was updated successfully, but these errors were encountered: