今天,我的托管服务提供商告诉我必须立即阻止我的数据库。我有一个查询会在服务器上造成巨大的负载。您知道如何优化我的查询以减少服务器的负载吗?
SELECT `users`.`id`,
`why_me`,
`created`,
`thumbnail`,
`rating_date`,
CONCAT(first_name, ' ', last_name) AS name,
SUBSTRING(why_me, 1, 27) as subwhy,
COUNT(`rating_date`) AS total,
MAX(`rating_date`) AS maxrate
FROM (`user_profiles`)
LEFT OUTER JOIN `rates` ON `user_profiles`.`id`=`rates`.`user_id`
JOIN `users` ON `user_profiles`.`user_id`=`users`.`id`
WHERE `users`.`activated` = '1'
AND `last_name` != ""
AND `first_name` != ""
AND concat_ws(' ', first_name, last_name) COLLATE UTF8_GENERAL_CI LIKE '%%'
GROUP BY `user_profiles`.`user_id`
ORDER BY `total` desc
我会很感激你的任何帮助。谢谢!