SELECT
*,
IFNULL(
(
SELECT
SUM(`rating`)
FROM
`shop_rating`
WHERE
`shop_rating`.`shop_id` = ur.`user_id`
GROUP BY
`shop_id`
LIMIT 1
),
0
)
+
IFNULL(
(
SELECT
SUM(`user_request_product_response`.`price`) / 1000
FROM
`user_request_product_response`
INNER JOIN
`user_response`
ON
`user_request_product_response`.`response_id` = `user_response`.`id`
WHERE
`user_request_product_response`.`user_id` = ur.`user_id`
AND
`user_response`.`is_confirmed_by_shop` = 1
) ,
0
)
AS rating,
(
SELECT
`shop_rating`.`date` as rating_id
FROM
`shop_rating`
WHERE
`shop_rating`.`response_id` = ur.`id`
ORDER BY `shop_rating`.`date` DESC
LIMIT 1
) as rating_last_date
FROM
`user_response` as ur
WHERE
ur.`is_accepted` = 1
AND
ur.`is_confirmed_by_shop` = 0
AND
ur.`created_at` < NOW() - INTERVAL 1 HOUR
HAVING
rating_last_date IS NOT NULL
AND
rating_last_date < NOW() - INTERVAL 1 HOUR
О_о я вообще в шоке со своего запроса. У меня ощущение, что при 1000 записей в каждой таблице он нахрен положит базу