PHPackages                             aaronfrancis/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. aaronfrancis/fast-paginate

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

aaronfrancis/fast-paginate
==========================

Fast paginate for Laravel

v2.0.0(1y ago)1.4k532.6k↓49.2%70[4 issues](https://github.com/aarondfrancis/fast-paginate/issues)[2 PRs](https://github.com/aarondfrancis/fast-paginate/pulls)4MITPHPPHP ^8.1CI passing

Since Jul 7Pushed 7mo ago11 watchersCompare

[ Source](https://github.com/aarondfrancis/fast-paginate)[ Packagist](https://packagist.org/packages/aaronfrancis/fast-paginate)[ Fund](https://aaronfrancis.com/backstage)[ GitHub Sponsors](https://github.com/aarondfrancis)[ RSS](/packages/aaronfrancis-fast-paginate/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (5)Versions (20)Used By (4)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/5e6901be7c1ba95be374eab0509862ebdf507bbe4c11705698d0f18e223ee390/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6161726f6e6672616e6369732f666173742d706167696e617465)](https://packagist.org/packages/aaronfrancis/fast-paginate)[![Total Downloads](https://camo.githubusercontent.com/e3559060a4e714689ceeb4d0015830f83a16ca433d28f577162da2da0f061ca3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6161726f6e6672616e6369732f666173742d706167696e617465)](https://packagist.org/packages/aaronfrancis/fast-paginate)[![License](https://camo.githubusercontent.com/a192851074e5c8876e2838abaefa225ab9c6ff30317d62bc2a9341e345168e91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6161726f6e6672616e6369732f666173742d706167696e617465)](https://packagist.org/packages/aaronfrancis/fast-paginate)

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/aarondfrancis/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 10, 11, and 12, and requires PHP 8.2 or higher.

To install, require the package via composer:

```
composer require aaronfrancis/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! Or you can open a PR! 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)

License
-------

[](#license)

The MIT License (MIT).

Support
-------

[](#support)

This is free! If you want to support me:

- Sponsor my open source work: [aaronfrancis.com/backstage](https://aaronfrancis.com/backstage)
- Check out my courses:
    - [Mastering Postgres](https://masteringpostgres.com)
    - [High Performance SQLite](https://highperformancesqlite.com)
    - [Screencasting](https://screencasting.com)
- Help spread the word about things I make

Credits
-------

[](#credits)

Fast Paginate was developed by Aaron Francis. If you like it, please let me know!

- Twitter:
- Website:
- YouTube:
- GitHub:

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance54

Moderate activity, may be stable

Popularity62

Solid adoption and visibility

Community32

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 78.5% 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.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~167 days

Total

18

Last Release

494d ago

Major Versions

v0.1.12 → v1.0.02023-04-28

v1.1.1 → v2.0.02025-02-25

PHP version history (2 changes)v0.1.0PHP ^7.4|^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/033238953a59b9223a1bde703b5e4254e63c7412195da1cb9de5af44bf53fc0a?d=identicon)[aarondfrancis](/maintainers/aarondfrancis)

---

Top Contributors

[![aarondfrancis](https://avatars.githubusercontent.com/u/881931?v=4)](https://github.com/aarondfrancis "aarondfrancis (117 commits)")[![atapatel](https://avatars.githubusercontent.com/u/11732316?v=4)](https://github.com/atapatel "atapatel (7 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (6 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 commits)")[![jfoulquie-tnw](https://avatars.githubusercontent.com/u/159464174?v=4)](https://github.com/jfoulquie-tnw "jfoulquie-tnw (4 commits)")[![hebinet](https://avatars.githubusercontent.com/u/24890467?v=4)](https://github.com/hebinet "hebinet (2 commits)")[![bradleybernard](https://avatars.githubusercontent.com/u/1431995?v=4)](https://github.com/bradleybernard "bradleybernard (1 commits)")[![hungthai1401](https://avatars.githubusercontent.com/u/22017922?v=4)](https://github.com/hungthai1401 "hungthai1401 (1 commits)")[![rodrigopedra](https://avatars.githubusercontent.com/u/5470108?v=4)](https://github.com/rodrigopedra "rodrigopedra (1 commits)")[![rubenvanerk](https://avatars.githubusercontent.com/u/20305359?v=4)](https://github.com/rubenvanerk "rubenvanerk (1 commits)")[![santutu](https://avatars.githubusercontent.com/u/28470293?v=4)](https://github.com/santutu "santutu (1 commits)")[![Naoray](https://avatars.githubusercontent.com/u/10154100?v=4)](https://github.com/Naoray "Naoray (1 commits)")[![krsriq](https://avatars.githubusercontent.com/u/2337648?v=4)](https://github.com/krsriq "krsriq (1 commits)")

---

Tags

laravelpagination

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-settings

Store your application settings

1.5k7.3M152](/packages/spatie-laravel-settings)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

198321.1k](/packages/fumeapp-modeltyper)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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