I'm building an API and I would like to know what is the best way to paginate in symfony (v4) and doctrine ORM.
I've used some bundles such as knp paginator and Pagerfanta,but I'm asking because I'm concerned with performance when we have much data in the DB. would't be better to use Doctrine's Paginator and implements a pagination by myself ?
thanks.
It's hard to answer if you didn't mention how much data you expect.
For now, I would simply use whiteoctober/Pagerfanta
.
I use Pagerfanta
to paginate results of ~200 000 000 records from single Postgres table.
There are no performance issues.
It is also used in official Symfony 4 demo.
Implementing your own, more efficient paginator - to me will always sound like a great idea (and challenge). But you won't be able to check it's efficiency without having expected amount of data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With