PHPackages                             tool3/fast-paginate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tool3/fast-paginate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tool3/fast-paginate
===================

Fast paginate for Laravel

1736↓50%PHP

Since May 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dungphanxuan84/fast-paginate)[ Packagist](https://packagist.org/packages/tool3/fast-paginate)[ RSS](/packages/tool3-fast-paginate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Fast Paginate for Laravel
=========================

[](#fast-paginate-for-laravel)

About
-----

[](#about)

This is a fast `limit`/`offset` pagination macro for Laravel. It can be used in place of the standard `paginate` methods.

This package uses a SQL method similar to a "deferred join" to achieve this speedup. A deferred join is a technique that defers access to requested columns until *after* the `offset` and `limit` have been applied.

In our case we don't actually do a join, but rather a `where in` with a subquery. Using this technique we create a subquery that can be optimized with specific indexes for maximum speed and then use those results to fetch the full rows.

The SQL looks something like this:

```
select * from contacts              -- The full data that you want to show your users.
    where contacts.id in (          -- The "deferred join" or subquery, in our case.
        select id from contacts     -- The pagination, accessing as little data as possible - ID only.
        limit 15 offset 150000
    )
```

> You might get an error trying to run the query above! Something like `This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery.`In this package, we run them as [two *separate* queries](https://github.com/hammerstonedev/fast-paginate/blob/154da286f8160a9e75e64e8025b0da682aa2ba23/src/BuilderMixin.php#L62-L79) to get around that!

The benefits can vary based on your dataset, but this method allows the database to examine as little data as possible to satisfy the user's intent.

It's unlikely that this method will ever perform worse than traditional `offset` / `limit`, although it is possible, so be sure to test on your data!

> If you want to read 3,000 words on the theory of this package, you can head over to [aaronfrancis.com/2022/efficient-pagination-using-deferred-joins](https://aaronfrancis.com/2022/efficient-pagination-using-deferred-joins).

Installation
------------

[](#installation)

This package supports Laravel 8, 9, and 10. (Laravel 8 must be 8.37 or higher.)

To install, require the package via composer:

```
composer require hammerstone/fast-paginate

```

There is nothing further you need to do. The service provider will be loaded automatically by Laravel.

Usage
-----

[](#usage)

Anywhere you would use `Model::query()->paginate()`, you can use `Model::query()->fastPaginate()`! That's it! The method signature is the same.

Relationships are supported as well:

```
User::first()->posts()->fastPaginate();
```

A Favor
-------

[](#a-favor)

If this helps you, please [tweet at me](https://twitter.com/aarondfrancis) with before and after times! I'd love to know :D

Some community results so far:

- [30 seconds --&gt; 250ms](https://twitter.com/mdavis1982/status/1482429071288066054)
- [28 seconds --&gt; 2 seconds](https://twitter.com/joecampo/status/1483550610028957701)
- [7.5x faster](https://twitter.com/max_eckel/status/1483764319372333057)
- [1.1 seconds --&gt; 0.1 seconds](https://twitter.com/max_eckel/status/1483852300414337032)
- [20 seconds --&gt; 2 seconds](https://twitter.com/1ralphmorris/status/1484242437618941957)
- [2 seconds --&gt; .2 seconds](https://twitter.com/julioelpoeta/status/1549524738980077568)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/43c64b60292d800ffac39451e9afc7200eea521096abbd3a56439ba51aebedd1?d=identicon)[dungphanxuan84](/maintainers/dungphanxuan84)

---

Top Contributors

[![vaix-dungpx](https://avatars.githubusercontent.com/u/114124789?v=4)](https://github.com/vaix-dungpx "vaix-dungpx (2 commits)")

### Embed Badge

![Health badge](/badges/tool3-fast-paginate/health.svg)

```
[![Health](https://phpackages.com/badges/tool3-fast-paginate/health.svg)](https://phpackages.com/packages/tool3-fast-paginate)
```

###  Alternatives

[ericclemmons/rules-bundle

Configuration-based logic for your domain models

2013.8k](/packages/ericclemmons-rules-bundle)[mouf/html.widgets.statsgrid

This PHP package contains a HTML pivot table. You provide it with a data set and the list of columns and rows and it will display a nice pivot table.

239.8k](/packages/mouf-htmlwidgetsstatsgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
