Laravel provides normal pagination:
$users = User::paginate(20);
This provides page metadata such as:
current_page
last_page
total
per_page
simplePaginate() avoids the total-count query:
User::simplePaginate(20);
For very large datasets, cursor pagination can be more efficient:
User::orderBy('id')->cursorPaginate(20);
Scenario
For an admin dashboard with 5,000 users, standard pagination may be perfectly reasonable.
For an API serving millions of records and clients repeatedly requesting the next page, cursor pagination can avoid expensive large OFFSET operations.
A stable, indexed ordering column is important for cursor pagination.
0 comments:
Post a Comment
Thanks