Open adantart opened 1 year ago
I know this is AWFUL code ... but just to show you ...
If withSettings method (in HasSettings) is replaced by this:
return static::select('users.id')->join('property_bag', 'property_bag.resource_id', 'users.id')
->where('key', '=', $key)
->where('value', '=', '"'.addslashes(json_encode([$value])).'"')->get();
it returns the same information, but avoiding doing as many queries as users having the setting requested.
Hi! Something should be wrong here ... When I do something like this:
it performs this query:
and also all these queries:
And this is in my development environment with 11 users ... I can't imagine if I have 3000 users and it has to do 3000 queries.
I think there's a missing "join" somewhere in the "withSetting" method.