When I use a Python script to update a MySQL table, I want to know the update details. So show processlist; after a while, we found that the process to which the script belongs is in sleep state. Run the show processlist command again, and the process resumes working.As shown in:
This repetition indicates that the process did not release resources in time after performing MySQL update or query operations. After a rough thought, when the MySQL connection is in sleep state, the Python script should still be calculating some data, but it has not been able to close () the connection or execute the next table operation.
I asked my predecessors and searched for information, and found that the facts are basically the same. During the database connection, the two major steps such as computing data and updating table data are repeated. Therefore, the MySQL execution status is always in sleep and working state.
Although it is a normal phenomenon, if sleep takes a long time, it may cause a loss of query and other operation efficiency, and optimization should be considered.
References:MySQL execution Status Analysis