Duplicate queries using bulk action
I'm getting a whole bunch of duplicate queries trying to use a bulkAction in my admin panel. I followed pretty much the docs as described here https://filamentphp.com/docs/2.x/tables/actions#custom-forms:
Attached is a screenshot of my debugbar when I open this resource on my admin panel. If I use a closure for
form()
I can defer the loading of departments until the bulk action is triggered, but it still does a bunch of duplicate queries. Is this normal?2 Replies
what is on line 84 of your resource
is it a Select field options()? maybe wrap those in
fn () =>
Sorry for late reply, had to switch to another project for a while. Wrapping the options paramter in
fn() =>
did the trick. I'll remember to do that in the future.
There are still duplicate queries for just fetching the selected entries though.
This one query is repeated 5 times when opening the bulk action form. Culprit seems to be
Conerns/CanSelectRecords
. Is there any way this can be cached for the request?