Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimal way to paginate in symfony 4

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.

like image 598
Jahir Nabil Avatar asked Jan 14 '18 13:01

Jahir Nabil


1 Answers

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.

like image 153
Łukasz D. Tulikowski Avatar answered Oct 15 '22 11:10

Łukasz D. Tulikowski