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

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

sergey-yabloncev/fast-paginate
==============================

Fast paginate for Laravel

11.0(2y ago)01.5kMITPHPPHP ^7.4|^8.0

Since Mar 21Pushed 3mo agoCompare

[ Source](https://github.com/sergey-yabloncev/fast-paginate)[ Packagist](https://packagist.org/packages/sergey-yabloncev/fast-paginate)[ RSS](/packages/sergey-yabloncev-fast-paginate/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

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

36

—

LowBetter than 79% of packages

Maintenance55

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~741 days

Total

2

Last Release

94d ago

PHP version history (2 changes)11.0PHP ^7.4|^8.0

v2.1.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32197653?v=4)[Sergey Yablontsev](/maintainers/sergey-yabloncev)[@sergey-yabloncev](https://github.com/sergey-yabloncev)

---

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)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/sergey-yabloncev-fast-paginate/health.svg)](https://phpackages.com/packages/sergey-yabloncev-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)
