I have a select multiple field on my Media Resource, with a dropdown to select from the Products table.
My Media model has uses a relationship to my Product model. My Product model is quite large, but nothing I can do about that at this stage as it has a lot of different fields.
I can see it can take up to 15 seconds to get a response for the user when they type a phrase into the search.
I am already using: ->searchable(['admin_designation', 'sku']) ->searchDebounce(2000) ->optionsLimit(5)
Looking at Laravel Debugbar, I can see that the query is actually returning all the product fields, not just the fields that are being searched.
"select distinct
product
product
.* from
product
product
left join
media_product
media_product
on
product
product
.
id
id
=
media_product
media_product
.
product_id
product_id
where (
admin_name
admin_name
like '%937031%') and
product
product
.
deleted_at
deleted_at
is null order by
product
product
.
admin_name
admin_name
asc limit 5"
Within MySQL, I can speed the query up significantly by only returning product.sku, or product.id, so I suspect actually it's Filament or Livewire trying to load the data into the browser which is slowing us down - a request is around 35 mb.
Is there a way to limit the underlying search query on a select multiple to speed up the search, does anyone know please?