查询当前正在运行的SQL语句[MySQL防范]
本文“查询当前正在运行的SQL语句[MySQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
查询当前正在运行的SQL语句,通过status号令,查看Slow queries这一项,假如值长时间>0,阐明有查询履行时间太长
以下为引用的内容:
MySQL> status;
--------------
mysql Ver 11.18 Distrib 3.23.58, for redhat-Linux-gnu (i386)
Connection id: 53
Current database: (null)
Current user: root@localhost
Current pager: stdout
Using outfile: ’’
Server version: 5.0.37-log
Protocol version: 10
Connection: Localhost via Unix socket
Client characterset: latin1
Server characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 4 days 16 hours 49 min 57 sec
Threads: 1 Questions: 706 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables:
52 Queries per second avg: 0.002
--------------
这时再通过show processlist号令来查看当前正在运行的SQL,从中找出运行慢的SQL语句,找到履行慢的语句后,再用explain号令查看这些语句的履行筹划.
mysql> show processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 53 | root | localhost | NULL | Query | 0 | NULL | show processlist |
+----+------+-----------+------+---------+------+-------+------------------+
以上是“查询当前正在运行的SQL语句[MySQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |