Memory Exhaustion in table
Hey I am running into an issue where memory is exhausted.
I have this select:
If I comment it out it will work smooth but this error which selects about 20k records to choose from or to search from kills the application.
Any suggestion on how to improve the performance?
This select is used in a repeater. So it could be that for each record in the repeater it will execute this query.
Solution:Jump to solution
I used the methods shown here to implement custom searching: https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
5 Replies
Do you need to show all 20k options, or can they be searched?
They can be searched
It doesn't work when I remove preload either
This issue is really blocking me. Does anyone have an idea what goes wrong over here?
Solution
I used the methods shown here to implement custom searching: https://filamentphp.com/docs/3.x/forms/fields/select#returning-custom-search-results
Just use
->getSearchResultsUsing()
, and ->getOptionLabelUsing()
(you have to use both), and in them, you can add a query with a limit, like you can see in the example. The only downside (or upside?) is that you have to implement the searching yourself.
If you're using this, probably remove the call to ->preload()
, I don't think it does anything in this caseHey thanks for your reply.
This will help me with searching. The problem is before searching namely loading som options into the select. I guess I would load maybe the first 25 products and then they should be able to search for the other ones...
I think this did the trick. Altough it is still kind of slow , it worked. So I preloaded 50 items and then added the searchable functions to be able to find the other stuff