- 论坛徽章:
- 0
|
近段时间,网站偶尔会卡,top查看发现mysql CPU占用率高,估计是部分SQL语句有问题,所以想优化。
查询了资料,发现mysql可以在日志里记录慢查询,所以修改my.cnf文件
log_slow_queries = /usr/local/mysql/var/slow_queries.log #慢查询日志路径
long_query_time = 10 #记录SQL查询超过10s的语句
log-queries-not-using-indexes = 1 #记录没有使用索引的sql
启程mysql后, 发现确实产生了日志文件slow_queries.log,但打开后却是:
SET timestamp=1381986711;
select count(pid) as c from lr_ordersession where oid='240171381986710';
# User@Host: mengtor[mengtor] @ localhost []
# Query_time: 0.000130 Lock_time: 0.000024 Rows_sent: 0 Rows_examined: 59
SET timestamp=1381986711;
select * from lr_productspic where pid=4586 order by pcid desc;
# User@Host: mengtor[mengtor] @ localhost []
# Query_time: 0.001333 Lock_time: 0.000357 Rows_sent: 10 Rows_examined: 91
SET timestamp=1381986711;
select pid,productpic,productstitle,newicon,cid,availability,oneprice from lr_products where cid in(0,......
就是说将所有的sql语句都记录了, long_query_time这个参数无效。
请大家帮忙看看,非常感谢!
PS:系统配置
ubuntu:1210
PHP:5.3.2-1
mysql: 5.1.41-3 |
|