Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

devaxises's avatar

Fetch One Million Record

i want to fetch 1 million rows thats likely to increase to 3 million in few weeks, please does anyone have a good techniques to fetch it. its been difficult fetching the record as it currently hangs my browser.

0 likes
7 replies
Cronix's avatar

Pagination. I doubt you have enough ram, etc, to load 1M records. Usually you paginate through that many.

Why do you need to fetch 1M at once?

devaxises's avatar

its users record, so i need to view all users, what techniques do you suggest

Cronix's avatar

What I said...pagination. Have you ever been to a single site that lists 1M records without pagination? I doubt it!

Usually you get like maybe 25 records at a time. Page 1 has 1-25, page 2 has 26-50, etc.

Laravel makes this pretty easy. https://laravel.com/docs/5.6/pagination

devaxises's avatar

Thanks, i guess have seen the problem, i paginated and was slow, i actually had an issue with the model. have optimised it.

Cronix's avatar

Make sure your tables are properly indexed. Fields that you sort on should be. I have a lot more records than you, and it takes about 400ms to retrieve a page using multiple relationships.

If your question is answered, please mark the thread as solved.

2 likes
jlrdw's avatar

No one views 1 million records. Do a search and just get the records needed to view.

1 million records, seriously.

that'd be like doing a Google for everything Google has rather than say searching for dog salons.

I have never heard anything like this.

thats likely to increase to 3 million in few weeks

Even if you viewed a record per second you would have to sit there for 34 days to view all that.

You really need to take a few weeks and learn some database techniques before delving deep into laravel.

Please or to participate in this conversation.