N
N
ninja op op2020-11-29 17:57:37
SQL
ninja op op, 2020-11-29 17:57:37

How to speed up LeftJOIN LARAVEL?

There is a request like this:

AllItem::leftJoin('items',function($join) use ($case){
            $join->on('items.classid','=','all_items.classid');
            $join->where('items.case_id','=',$case->id);
        })->orderBy('items.created_at','desc')->select('all_items.*')->paginate(10);

Now its execution time takes about 30 seconds (sometimes longer).

There are ~80 thousand records in the `all_items` table, ~1500 records in the `items` table.

Is it possible to speed up the query execution time?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question