Home  >  Q&A  >  body text

mysql 查询语句性能分析

有什么工具可以分析记录 一条查询语句吗?比如说在那条语句中,查询哪个字段用时最多。

PHPzPHPz2731 days ago655

reply all(6)I'll reply

  • PHPz

    PHPz2017-04-17 13:07:47

    Records stored in mysql are generally not divided into fields and are stored as a whole.
    Tools for optimizing SQL include: explain: used to analyze whether to apply indexes and the number of scanned records; slow log generally records SQL statements whose execution time is greater than a certain value; show profiles generally analyzes data on IO, Memory, CPU, etc.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:07:47

    Use execution plan, explain

    reply
    0
  • 迷茫

    迷茫2017-04-17 13:07:47

    Set in my.cnf

    php[mysqld] 
    slow_query_log=on 
    slow_query_log_file=mysql-slow
    

    Slow query log analysis tool officially provided by mysqlmysqldumpslow mysql-slow
    Also mysqlsla

    reply
    0
  • 阿神

    阿神2017-04-17 13:07:47

    Use explain command

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:07:47

    Must explain

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:07:47

    It is recommended to use Alibaba's druid database connection pool. Configure it to record all SQL execution statistics for a period of time. There will be a web page that can be accessed, which is very helpful for SQL execution analysis. However, the cache of this thing takes up a lot of space, and it cannot count long-term running conditions. It is very suitable for analyzing the amount of data for several hours.

    reply
    0
  • Cancelreply