MySQL Query the currently running SQL statement _ MySQL

Source: Internet
Author: User
MySQL queries the currently running SQL statement by using the status command to view the Slow queries item. if the value is greater than 0 for a long time, it indicates that the query execution time is too long.

The following is a reference clip:

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 --------------

Then, run the show processlist command to view the currently running SQL statements, find slow SQL statements, find slow statements, and then run the explain command to view the execution plans of these 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.