我从我的网络托管公司收到通知,以优化我网站中的 MySQL 查询。他们告诉我,共享托管中不允许运行超过 15 秒的 MySql 查询,而该域的 mysql 查询运行时间超过 75 秒。
但我不知道该做什么以及在哪里更改以优化 MySQL 查询。请帮我解决这个问题。
User@Host: khabarin_suprusr[khabarin_suprusr] @ localhost []
Query_time: 76.546533 Lock_time: 1.408959 Rows_sent: 5 Rows_examined: 3038
use khabarin_portal3;
SET timestamp=1347378163;
SELECT *
FROM (`art_conts`)
JOIN `art_cats` ON `art_cats`.`cat_id`=`art_conts`.`cat_id`
JOIN `art_secs` ON `art_secs`.`sec_id`=`art_cats`.`sec_id`
WHERE `art_conts`.`cont_status` = 'public'
ORDER BY `cont_id` desc
LIMIT 5;
User@Host: khabarin_suprusr[khabarin_suprusr] @ localhost []** 强文本Query_time: 54.002604 Lock_time: 1.403354 Rows_sent: 1 Rows_examined: 3033**
use khabarin_portal3;
SET timestamp=1347376289;
User@Host: khabarin_suprusr[khabarin_suprusr] @ localhost []
Query_time: 24.436448 Lock_time: 13.889496 Rows_sent: 1 Rows_examined: 0
use khabarin_portal3;
SET timestamp=1347376151;
SELECT COUNT(*) AS `numrows`
FROM (`art_conts`)
JOIN `art_cats` ON `art_cats`.`cat_id`=`art_conts`.`cat_id`
JOIN `art_secs` ON `art_secs`.`sec_id`=`art_cats`.`sec_id`
WHERE `art_conts`.`cat_id` = '59'
AND `art_conts`.`cont_status` = 'public'
ORDER BY `cont_id` desc;