We sometimes encounter errors or slowdowns in the mysql database. At this time, we need to take a look at some basic situations
A bad SQL statement may make your entire program very slow. Is it because there are too many connections? Is there a problem with the table structure? The index of the table is not added? . .
Below are some mysql analysis statements that I commonly use, make a record.
Statement | Function | ||
show PROCESSLIST; | Displays all processes running in the system, that is, the query currently being executed. | Most users can view their own processes, but if they have process permissions, they can view everyone's processes, including passwords. | |
show status [ like "%Thread%]"; | Display some system-specific resource information, For example, the number of running threads. | ||
show variables [like '%profili%']; | Display the names and values of system variables. It is a system parameter that can be adjusted statically (my.cnf or statement adjustment) | ||
desc table_name; | Analysis Table structure | ||
show create table table_name; | View table creation statement | ||
show index from table_name; | View the index of the table | ||
show profiles; | View the status of executed statements | ||
explain sql; | Analyze statement execution status |