Open fruitl00p opened 2 months ago
Further inspection reveals that in the XHR request for /nova-api/ I can't alter the construction of the 'component' class to exclude all other relations (i.e. using a without()
call in the nova-api/-request. Also It seems that this is where the issue stems from; both Component and 'Product' and the Pivot have even more releations that are N+1 Queried multiple times... Hence the massive increase in (duplicate) queries.
Any way I can hook into this (without sacrificing the '$with = []' in my models?
Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)
Description:
We have a BelongsToMany relation which seems to do a lot of queries eventhough the original pivot is empty?
We have the following setup:
Model: Compontent
And in Nova we have:
When hitting the details page this incurs a
/nova-api/products?search
request with the following filter (shortened):This results in 14 queries of which 10 are duplicate?
(even though there were no relations)
If having 9 actual cook_products relations this balloons to 67 queries of which 7 where unique (!)
I'm not sure if this is a bug, a feature request or missing documentation. (or something else)