Discussion: Mysql How to query the currently running SQL statement _mysql

Source: Internet
Author: User
Through the status command, view slow queries this item, if the value is long >0, the query execution time is too long
Copy Code code as follows:

The following are the referenced contents:
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 hours sec
Threads:1 questions:706 Slow queries:0 opens:177 Flush Open tables:
Queries per second avg:0.002
--------------

At this point, the show Processlist command is used to view the currently running SQL, find out which SQL statements are running slowly, find the execution of the slow statements, and then use the explain command to view the execution plans for those statements.
Mysql> show Processlist;
+----+------+-----------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+-------+------------------+
| 53 | Root | localhost | NULL | Query | 0 | NULL | Show Processlist |
+----+------+-----------+------+---------+------+-------+------------------+

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.