Laravel slow simple query with Eloquent

memoadian :

I have a problem with a query with laravel, I have a database with 250k records called orders

When I try to get a paginated orders by client_id, I get 504 time out.

The query is very simple.

$ordenes = Order::where('client_id', $id)->orderBy('id', 'desc')->paginate(20);

My temporary solution was increment from 1gb RAM to 2gb and 1cpu to 2cpu's. But I want to know if it's posible optimize this simple query to get a faster response.

GarnachaSoft :

Make sure you don't have another related table, eloquent is a little more slow, than query builder, but not so much.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=34408&siteId=1