Suggestions for querying MySQL processlist

Source: Internet
Author: User

query The MySQL process because the database has a lot of sleep connections (usually around thousands of), do not recommend direct show Processlist or show full

Processlist

try to use Select query

the thread being running

Select Count (*) from Information_schema.processlist where info was not null;

All Mysql Threads

Select Count (*) from information_schema.processlist;

Query the current running SQL for the longest execution time

Select * Frominformation_schema.processlist where info is not NULL for ORDER by time Desc limit10;

Query The number of connections to the IP executing SQL

Select Left (host,instr (host, ': ')-1) asip,count (*) as Num from information_schema.processlist GROUP by IP ORDER by num DESC ;

Query The number of user connections that Execute SQL

Select User,count (*) as Num from Information_schema.processlist GROUP by Userorder by num DESC;

Number of query execution SQL statements

Select COUNT (*) as Num,info from information_schema.processlist where info isnot null GROUP BY info ORDER by NUM;

query mysql server maximum connections, current database connections and running number show global variables like ' max_connections ';

Show global status like ' threads% ';

Query user maximum number of connections

Show grants for ' MYSQL_BI ';

Slave error problem, need to confirm data inconsistency reason

ADM and Click Libraries can skip 1 errors directly

the general processing methods include

kill slow query process, can be done for the user, execution time to operate

Select Concat (' KILL ', id, '; ') frominformation_schema.processlist where user= ' user name ' and Time>100into OutFile '/tmp/aa.txt ';

Source/tmp/aa.txt


This article from "Cloud Light Breeze Light" blog, declined reprint!

Suggestions for querying MySQL processlist

Related Article

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.