How to view the execution status of SQL in MySQL?

In MySQL, you can monitor SQL execution using the SHOW STATUS command. Here are the specific steps:

  1. Open the MySQL command line tool or MySQL graphical tool.
  2. Connect to the database you want to view SQL execution.
  3. Use the following command to check the status of SQL execution:
SHOW STATUS LIKE 'Com_%';

This command will display various counters starting with Com_ to represent the number of times different types of SQL operations have been executed. For instance, Com_select represents the number of times SELECT statements have been executed, Com_insert represents the number of times INSERT statements have been executed, and so on.

In addition, you can use the SHOW PROCESSLIST command to view the SQL statements that are currently being executed. This command will display all processes connected to the database and their corresponding SQL statements. For example:

SHOW PROCESSLIST;

The above command will display detailed information about all processes currently connected to the database, including process ID, user, host, database, status, execution time, and more.

广告
Closing in 10 seconds
bannerAds