Home  >  Q&A  >  body text

php - A website running online, how to check whether which sql statement needs optimization?

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

天蓬老师天蓬老师2714 days ago660

reply all(5)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-06-05 11:09:52

    Slow query log.

    reply
    0
  • ringa_lee

    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

    reply
    0
  • 巴扎黑

    巴扎黑2017-06-05 11:09:52

    If it is Laravel, you can use debugbar https://github.com/barryvdh/l...

    reply
    0
  • 黄舟

    黄舟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.

    reply
    0
  • PHPz

    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.

    reply
    0
  • Cancelreply