How to limit the results displayed on a table for tables with more than 1M records
I have a table with 7 million records, the default pagination I have is 50 per page.
Every time I need to paginate, the loading of the page is slow (I have indexes on the table).
- Does anyone know what is the best approach for big tables ?
- Can I limit the results to 10K by default ?
Any suggestion is welcomed.
10 Replies
Maybe you could use this filtering the eloquent query https://filamentphp.com/docs/3.x/panels/resources/listing-records#customizing-the-table-eloquent-query
hi there guys! I also need to limit table results. please guide me how to do it. $query->limit(100)->get() won't work.
Did you find a solution?
Yeah. You just need to disable pagination and your limit() will work. Laravel pagination feature overrides limit(). So when you disable pagination, it will work already.
I have almost a million records though so i cannot disable pagination or else it would crash showing almost a million records at once. What i did was to just to add query->where("id", "<", 800000).
Works for me. Its just that >800000 wont be included in the results.
Thanks! I will try that π Wonder what it would be if I would like to have paginate but with a limit. E.g. only the first 100 records with 10 on each page.
Have a look at this too, It might help https://v2.filamentphp.com/tricks/fast-table-pagination
Filament
Fast table pagination by Dan Harrin - Tricks - Filament
Filament is a collection of tools for rapidly building beautiful TALL stack apps, designed for humans.
does that also apply for v3?
Yeap, it should AFAIK
Filament
How to improve table pagination performance by Dan Harrin - Filament
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
Thank you very much! This looks very interesting ππΌ