Home Database Mysql Tutorial MySQL如何查询当前正在运行的SQL语句

MySQL如何查询当前正在运行的SQL语句

Jun 07, 2016 pm 04:07 PM
mysql sql how Inquire statement pass

通过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 us

通过status命令,查看Slow queries这一项,如果值长时间>0,说明有查询执行时间过长

以下是引用片段:

<p> mysql&gt; status; <br>-------------- <br>mysql Ver 11.18 Distrib 3.23.58, for redhat-linux-gnu (i386) <br>Connection id: 53 <br>Current database: (null) <br>Current user: root@localhost <br>Current pager: stdout <br>Using outfile: '' <br>Server version: 5.0.37-log <br>Protocol version: 10 <br>Connection: Localhost via UNIX socket <br>Client characterset: latin1 <br>Server characterset: latin1 <br>UNIX socket: /tmp/mysql.sock <br>Uptime: 4 days 16 hours 49 min 57 sec <br>Threads: 1 Questions: 706 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables:</p><p>52 Queries per second avg: 0.002 <br>-------------- </p>
Copy after login


这时再通过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 |

+----+------+-----------+------+---------+------+-------+------------------+


【相关文章】

  • 诊断Oraacle数据库Hanging问题
  • MySQL与标准的兼容性
【责任编辑:碧海蓝天 TEL:(010)68476606】
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

PHP's big data structure processing skills

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

What are the application scenarios of Java enumeration types in databases? What are the application scenarios of Java enumeration types in databases? May 05, 2024 am 09:06 AM

What are the application scenarios of Java enumeration types in databases?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

See all articles