Very very slow to speed up

Posted 1 year ago by deansatch

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::
        withCount(['classes' => $subQuery])
        ->withCount(['bookings' => $subQuery2])

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.