Level 55
hi @joshsalway
You can play with the query itself. For example, rewrite it to something like:
$countLeaseCommercial = DB::table('properties')
->whereExists(function ($query) {
$query->select(DB::raw(1))
->from('listings')
->whereRaw('properties.id = listings.property_id')
->where('properties.type', '=', 'Commercial');
})
->where('listings.status', '=', 'Leased')
->where('listings.user_id', '=', $this->user->id)
->count();
Also you can make index in mysql columns you filtered on (properties -> type, listings -> status), and be sure that user_id and property_id are indexes too