I have this:
$subQuery = function($q)use($start, $end){ $q->whereHas('classdates', function($q)use( $start, $end){ $q->whereBetween('datetime',[ $start, $end]); ); }; $subQuery2 = function($q)use($start, $end){ $q->whereHas('classes.classdates', function($q)use( $start, $end){ $q->whereBetween('datetime',[ $start, $end]); }); }; $studios = \App\Studio:: select('name')-> withCount(['classes' => $subQuery]) ->withCount(['bookings' => $subQuery2]) ->get();
It takes about 20 seconds to run just for a one month date range and I need it to run for full years or even more.
Is there a way I could speed this up?
Please sign in or create an account to participate in this conversation.
Reply to
Use Markdown with GitHub-flavored code blocks.
There's no shortage of content at Laracasts. In fact, you could watch nonstop for days upon days, and still not see everything!
Get Started
Very very slow query...how to speed up
I have this:
It takes about 20 seconds to run just for a one month date range and I need it to run for full years or even more.
Is there a way I could speed this up?