Unnecessary SQL in select filter using relations
I am using SelectFilter with preload, when the page loads the SQL is being executed, but the select does not show any data, so, every time you click on the select, it makes another call to the server and performs another SQL query, the same as the previous one.
Is there any way to avoid it?
16 Replies
try:
It is the same, when I access the index, where the table and the filtering are, the SQL is executed, and when I open the filtering and click in select Roles, the SQL is executed again
If you remove Multiple() does it remove it?
No
/admins
Click in select filter Roles
It must be skipping the preload check, so preload is working but then on click it's reloading. Can you submit a bug with a reproduction repo?
I don't really know how to do that
Ok, I wouldn't really worry about it too much as it stands it's a single query. But if I get time I'll look into it
Do you mean opening an issue on github?
Yes
ok, now i put it
I thought it was something else
GitHub
SelectFilter->preload it skips the preload check · Issue #11421 · f...
Package filament/filament Package Version 3.2.34 Laravel Version 10.44.0 Livewire Version 3.4.4 PHP Version 8.3.1 Problem description I am using SelectFilter with preload, when the page loads the S...
One solution I found, is to not use relationship() and instead use options() and query() to filter the results
Interesting, please do note that in the PR
Ideally, relationship() would have to take care of everything, but since that's not working well, what I'm using now is options() to get the data from the database and query to filter the results from the table .
When using options(), there is no need to use preload()