Open the server task manager and find that the CPU process has always been 99%, and the view is occupied by the mysql process, which has been high.
The output of the processlist command shows which threads are running, and you can check the current running status of the database.
1. Go to the mysql/bin directory and enter mysqladmin processlist; 2. Start mysql and enter show processlist. If you have SUPER permission, you can see all threads, otherwise, you can only see the threads of your account.
The meaning and purpose of each column
id: An identifier user: displays the current user, if it is not root, this command will only display SQL statements within your permissions. host: shows which IP this statement is coming from which port db: Displays the database that the process is currently connected to. command: Displays the commands executed by the current connection, usually sleep, query, and connect. time: The time this state lasts, in seconds. state: Displays the status of the sql statement that uses the current connection, but only a certain state in the execution of the statement, a sql statement, has been queried, for example, it may need to go through the copying to tmp table, Sorting result, Sending data, etc info: Displays this SQL statement, because the length is limited, so the long SQL statement is not fully displayed, but it is an important basis for judging the problem statement.
It is found that there are two SQL query statements that take the longest time and have not been executed for more than 1000 seconds, and the SQL statements we copied from the info field are a joint query, as follows:
select cast(count(*) as SIGNED) as col_0_0_ from `RatedPassenger` ratedpasse0_, `BaseInfoCompany` baseinfoco1_, `OrderMatch` ordermatch2_ where baseinfoco1_. CompanyId=ratedpasse0_. CompanyId and ordermatch2_. OrderId=ratedpasse0_. OrderId We kill the process of these two query statements
After waiting for 10 seconds, I found that the CPU had dropped a lot, but it was still very high, and I will continue to query the reason!
For the join joint query statement, add an index to the associated field or modify the program query code. Create an index SQL statement
End
|