演示数据:
http://dev.mysql.com/doc/sakila/en/sakila-installation.html
show variables like '%slow_query%';
set global slow_query_log_file = '路径'; //设置慢查询日志路径
set global log_queries_not_using_indexs = on; //记录下没有使用索引的sql
set global long_query_time = 1; // 定义多少时间算慢查询
慢查询分析工具
mysqldumpslow :
1.优化表的数据类型
2.通过拆分提高表的访问效率
3.逆规范化
4.使用中间表提高统计查询速度
http://www.php.cn/mysql-tutorials-365969.html
http://www.php.cn/mysql-tutorials-354533.html
http://www.php.cn/mysql-tutorials-354530.html