Mysql中两个有用的sql性能分析语句
1> explain SQL,类似于Oracle中explain语句
例如:explain select * from nad_aditem;
2> select benchmark(count,sql);计算sql语句执行count次所花费的时间
例如:
mysql> select benchmark(1000,"SELECT * FROM AD");
+----------------------------------------+
| benchmark(1000,"SELECT * FROM AD") |
+----------------------------------------+
| 0 |
+----------------------------------------+
1 row in set (0.02 sec)
+----------------------------------------+
| benchmark(1000,"SELECT * FROM AD") |
+----------------------------------------+
| 0 |
+----------------------------------------+
1 row in set (0.02 sec)
注意观察0.02这个时间,而且不能仅仅关注这个时间,还要观察CPU和系统的负载。