MySQL如何查询当前正在运行的SQL语句_MySQL
以下是引用片段:
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 |
+----+------+-----------+------+---------+------+-------+------------------+
推荐阅读
-
MySQL如何查询当前正在运行的SQL语句_MySQL
-
SQL语句中的一些参数如何用变量来代替?_MySQL
-
MySQL 查询随机条记录的sql语句和php计算概率
-
mysql 数据库事务 (三)查询及杀死正在运行的 有哪些事务、都锁定哪些资源
-
【Mysql】shell运行mysql的sql语句_MySQL
-
查询当前持有锁的sql_MySQL
-
oracle查询当前运行的进程、查询被锁的对象、杀Seesion的SQL、设置SQL语句计时等教程
-
MySQL5.6如何优化慢查询的SQL语句--慢日志介绍_MySQL
-
MySql的sql语句涉及group/sum/limit/结果集多字段,如何写
-
mysql-求助MySQL的关于sql语句怎么写??三表的查询~~~请大神进来帮忙~~~~~