Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.
This repository was archived by the owner on Jul 16, 2021. It is now read-only.

Improve pagination performance without using OFFSET #1347

@yaquawa

Description

@yaquawa

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

public function paginateAfter
(
$cursor, // the value of cursor. for example `212`
$cursorColumn, // the column name of cursor. for example `id`
$perPage = null,
$columns = ['*'],
$pageName = 'page',
$page = null
)

What do you think?
If this is OK to have I'll send a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions