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

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

friendsofhyperf/fast-paginate
=============================

Fast paginate for Hyperf.

v3.1.75(5mo ago)363MITPHP

Since Feb 18Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/fast-paginate)[ Packagist](https://packagist.org/packages/friendsofhyperf/fast-paginate)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-fast-paginate/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (36)Used By (0)

Fast Paginate for Hyperf
========================

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

> Fork from

About
-----

[](#about)

This is a fast `limit`/`offset` pagination macro for Hyperf. 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 Hyperf 3.0+.

To install, require the package via composer:

```
composer require friendsofhyperf/fast-paginate
```

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

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 [start me](https://github.com/friendsofhyperf/fast-paginate) 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)

Contact
-------

[](#contact)

- [Twitter](https://twitter.com/huangdijia)
- [Gmail](mailto:huangdijia@gmail.com)

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance76

Regular maintenance activity

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~29 days

Recently: every ~74 days

Total

35

Last Release

161d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8337659?v=4)[Deeka Wong](/maintainers/huangdijia)[@huangdijia](https://github.com/huangdijia)

---

Top Contributors

[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (32 commits)")

---

Tags

hyperfv3.1

### Embed Badge

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

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

###  Alternatives

[hyperf/crontab

A crontab component for Hyperf.

131.6M62](/packages/hyperf-crontab)[friendsofhyperf/sentry

The sentry component for Hyperf.

1864.6k](/packages/friendsofhyperf-sentry)

PHPackages © 2026

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