When MySQL takes up a large amount of CPU resources, it can be analyzed by viewing the currently executed SQL statements. This analysis method is suitable for Windows and Linux operating systems.
After remotely connecting to the cloud server, execute the following command. If it is a Windows operating system, it needs to switch to the bin directory under the mysql directory for execution.
mysql -uroot -p
Enter password:
mysql> show full processlist;
A complete example is as follows.
Use this method to list the currently executed SQL statements, and then use the explain command to view the execution efficiency of the statements, mainly looking at the amount of data and execution efficiency, and determine whether to establish an index according to the actual situation.
phpMyAdmin can also view the currently executed SQL statements. As shown below, after logging in, click "Status = ยป Process" to view.
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58