For example, if a website is running online and it is found that a certain page loads very slowly, how to check whether which SQL statement needs to be optimized
ringa_lee2017-06-05 11:09:52
Check the log and find the corresponding sql desc or explain select....(your sql statement) to check the efficiency, or write the execution efficiency directly to the log
黄舟2017-06-05 11:09:52
In the configuration of mysql, enable slow query slow_query_log and statement without index log_queries_not_using_indexes. You can use the explain + sql statement to check the execution efficiency of sql.
You should also pay attention to whether it can be optimized in the program. Don't put database queries in loops.
PHPz2017-06-05 11:09:52
Have you used a framework? You can monitor the running time of each SQL. And record the logs and analyze them one by one.