Slow query: SQL statements that exceed the set time are recorded in the specified file
1. Watch MySQL Slow query default time (default 10 seconds)
Show variables like ' long% ';
2, modify the slow query set time
Set long_query_time=1;
3. Check if MySQL turns on automatic recording (default off)
Show variables like ' slow% ';
4. Turn on MySQL automatic recording function
Set global slow_query_log=on;
Show variables like ' slow% ';
5. Specify the SQL statement to save the path
Set global slow_query_log_file= ' C:\\log.txt ';
Show variables like ' slow% ';
To view the SQL statement execution time
1, check whether to open the SQL statement query time
Show variables like ' profiling% ';
2. Turn on MySQL Statistics SQL statement execution time
Set Profiling=on;
Show variables like ' profiling% '
3. Execute SQL statements
Select Kch from KCB where kcm= ' database ' or kcm= ' QTP ';
4. View execution Time
Show Profiles;
MySQL Database performance Chapter