In the daily development, often encounter the page open very slow situation, by excluding, determined, is the impact of the database, in order to quickly find the specific SQL, can be logged through the MySQL method.
--Open the SQL execution logging function
Set global log_output= ' TABLE '; --Output to table
Set global log=on; --Open all commands to perform the logging function General_log, all statements: successful and unsuccessful.
Set global log_slow_queries=on; --Open slow query SQL record Slow_log, execute successfully: Slow query statement and statement with unused index
Set global long_query_time=0.1; --Slow query time limit (seconds)
Set global log_queries_not_using_indexes=on; --Record SQL statements that do not use indexes
--Querying SQL execution records
SELECT * from Mysql.slow_log order by 1; --Successful execution: Slow query statements, and statements that do not use indexes
SELECT * from Mysql.general_log order by 1; --All statements: successful and unsuccessful.
--Close SQL execution record
Set global Log=off;
Set global Log_slow_queries=off;
--Long_query_time parameter description
--v4.0, 4.1, 5.0, v5.1 to 5.1.20 (included): Slow query parsing at millisecond level is not supported (1-10 seconds of support accuracy);
--5.1.21 and later versions: supports slow query analysis at millisecond level, such as 0.1;
--6.0 to 6.0.3: Slow query parsing at millisecond level is not supported (1-10 seconds for precision);
--6.0.4 and later: support for millisecond-level slow query analysis;
With the SQL recorded in the log, quickly locate the specific file, optimize SQL to see if the speed is improved?
RELATED LINKS