Duplicate queries using custom filter
This:
produces 1 query:
But if I change the closure to a simple
pluck
:
I get duplicate queries. Before the query above, the exact same query is executed 18 times.
I cannot relate the number 18 to anything. It's not the number of select options, or records in the result, or anything else I could think of.
If I do the same /* fn() => */
on another filter, the same thing happens and I end up with 36 duplicate queries.
Backtrace of the single query:
Backtrace of the duplicated query:
It's not a problem to always use a closure, I'm just trying to understand what's going on and prevent similar situations.4 Replies
The form schema is currently evaluated in multiple places and therefore your query is run multiple times if you don't wrap it inside a closure
Ok. So I guess it's recommended to always use a closure when a query is involved?
That's assuming there is no easy way to identify / prevent the cause of such duplicate queries.
I think this was fixed/recuded in V3. But yeah: Always use a closure.
Ok thanks!