sometimes we're less efficient in locating systems. Query syntax, you need to open the slow query log, which is slowquery Log . The command to open the slow query log is as follows:
View
Mysql> showvariables like '%slow% ';
+---------------------+-------------------------------------------+
| variable_name | Value |
+---------------------+-------------------------------------------+
|log_slow_queries | On |
|slow_launch_time |
|slow_query_log | On |
| slow_query_log_file| /app/mysql-5.5.32/data/localhost-slow.log |
+---------------------+-------------------------------------------+
4 rows in Set (0.00SEC)
Mysql> show globalstatus like '%slow% ';
+---------------------+-------+
| variable_name | Value |
+---------------------+-------+
| slow_launch_threads| 0 |
| slow_queries |
+---------------------+-------+
2 rows in Set (0.00SEC)
turning on the slow query log can have a little impact on system performance if your MySQL is a master-slave structure, you can consider opening one of the slow query logs from the server, so that you can monitor the slow query, the impact on the system performance will be very small. In addition, you can use the MySQL command mysqldumpslow to query.
For example, the following command can detect the most frequently accessed - a SQL statement:
[[Email protected] ~] #mysqldumpslow-S c-t 20/app/mysql-5.5.32/data/localhost-slow.log
Attention:
-S ORDER what to sort by (Al, at, AR, C, L, R, T), ' at ' IsDefault
Al:average Lock Time
Ar:average rows Sent
At:average Query Time
C:count
L:lock time
R:rows sent
T:query time
-T NUM just show the top n queries
This article is from a "a little" blog, make sure to keep this source http://pengai.blog.51cto.com/6326789/1890364
MySQL Slow query