Answer the question
In order to leave comments, you need to log in
Why does the application take a second longer when changing the sort?
There is a service in which sorting is added.
switch ($request->get('sort')) {
case 'rating':
$orderedQuery = $rawQuery->orderBy('rating', 'DESC');
break;
case 'price':
$orderedQuery = $rawQuery->orderBy('min_price', 'ASC');
break;
default:
$orderedQuery = $rawQuery->orderBy('internal_rating', 'DESC');
}
UPDATE doctors SET internal_rating=random();
Answer the question
In order to leave comments, you need to log in
The problem turned out to be serialization. Models with a higher rating had much more additional data (which is quite logical).
Copy the query and do EXPLAIN, compare the number of scanned rows, the use of indexes and their selectivity. Look at the number of requests and how much data they return.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question