Replies: 7 comments
-
Note: In a way, you'd expect things not to work 100% when the table is so large. Backpack couldn't possibly work fast, if the actual Laravel/MySQL query is slow. But on the other hand... I need to have a listing / filtering solution for a table this big. And I expect some people would too (though not a lot of people). I think it's a cool problem to solve. It won't impact 99.9% of the use cases, but since I need it for myself, I'm eager to see if we can find a decent solution for it. Posting here so I don't forget what I've already tried, and to see if anybody else has some bright ideas. |
Beta Was this translation helpful? Give feedback.
-
Why not provide different pagination style options?
For the search, it may not be very slow if you can send it to the right tool -> laravel scout -> ??? |
Beta Was this translation helpful? Give feedback.
-
Hey @ziming Thanks for input. Trully that was the only solution we have atm that we think will work best in this scenarios. Best, |
Beta Was this translation helpful? Give feedback.
-
Indeed that's the solution I thought would be simple to implement. But it's not that simple after all. Maybe I wasn't clear in my first post: even if you're not actually showing the total number anywhere inside the page, DataTables still requires you to send the total count on each AJAX request. It's a requirement if you're loading the entries using AJAX (which we are). Even if the pagination is just "Previous Next", DataTables uses the total count to figure out when the "Next" button should be disabled... So even if we do implement simple pagination for HUGE tables, we'll also need to do some dirty stuff to trick DataTables:
Soo... it's a solution... but it's not exactly a pretty one :-) Feels more like a hack. |
Beta Was this translation helpful? Give feedback.
-
In ListOperation where we call count() on the model, we could first check for a model function to implement total model count via some other means such as a counter table (of course they'd have to implement in application somehow). Though, I'm not sure this can be applied to the filtered rows query count. |
Beta Was this translation helpful? Give feedback.
-
Thanks for pitching in @ankurkwv . Indeed we could do that in the Model but:
Sad but true 😞 |
Beta Was this translation helpful? Give feedback.
-
Fixed a long time ago, in v6 - Backpack supports millions of records now - https://backpackforlaravel.com/docs/6.x/crud-operation-list-entries#large-tables-millions-of-entries So let's close this discussion. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug report
What I did
Created a CRUD for a table that has 91 million entries.
What I expected to happen
As expected, the create/update operations work well. I expected the List operation to work well too, expecially since I've personally tested it with millions of entries before (1-3 mil, never as high as 91).
What happened
ListOperation doesn't work. The page loads, but the AJAX request takes too much time, so after 1-2 minutes you're presented with a red error bubble saying something went wrong with the datas set.
What I've already tried to fix it
I've drilled down to find the bottleneck. And it's
count()
. InListOperation:70
we have:So we have two places where we do
count()
, and we do that in order to:But. Because it's such a big table, MySQL has a difficult time counting the number of rows. It takes more than 60 seconds to do a
count()
, rendering that ListOperation basically useless.I've tried to:
(1) Change the DataTables pagination to "full" in order to NOT show page numbers. Since the counts() are still executed in PHP, this is not an actual solution. The AJAX response loads just as slow.
(2) In addition to setting JS pagination to "full", to give it some ridiculously high count numbers (static), instead of doing the actual database
count()
. So basically:This works, but:
count()
is so slow, you bet your ass that Searching will also be super slow; so that doesn't work and should be hidden;count()
is so slow, clicking a column heading to sort by it is also super slow; so that doesn't work and should be hidden;count()
is so slow, I expect filtering to be just as slow; I don't expect to be able to add filters to db tables that are so huge;(3) You could theoretically get the total count from INFORMATION_SCHEMA instead of the actual table - which would not be 100% accurate all the time since it's cached, but it would be very close. I believe this is what DB Management Software like Sequel Pro / Tabler to. This would solve
$totalRows
, and be reasonably accurate. But it would still break the sorting / search / filtering. So the ListOperation will be a very basic thing.Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is:Beta Was this translation helpful? Give feedback.
All reactions