Comparison of mysql slow log analysis tools (1)

Source: Internet
Author: User
Tags perl script

The slow log in mysql is a log tool used to record SQL statements that have been executed for a long time (beyond long_query_time seconds.

Enable slow log

Set in my. cnf

 
 
  1. [mysqld] 
  2. slow_query_log=on 
  3. slow_query_log_file=mysql-slow 

Restart the MySQL service.

Five common tools

Mysqldumpslow

The log analysis tool for slow query officially provided by mysql. The output chart is as follows:

Main functions include calculating slow SQL statements

  • Count)
  • Average execution Time and total execution Time (Time)
  • Lock)
  • Total number of Rows sent to the client (Rows)
  • Total number of Rows scanned (Rows)
  • User and SQL statement itself (abstracted format, for example, limit 1, 20 is represented by limit N, N)

Mysqlsla

A log analysis tool launched by hackmysql.com (This website also maintains mysqlreport, mysq1_xchk, and other useful mysql tools ).

In general, the function is very powerful. The output data report is very helpful for analyzing the causes of slow queries, including the execution frequency, data volume, and query consumption.

The format is described as follows:

  • Total number of queries (queries total), number of SQL statements after deduplication (unique)
  • Sorted)
  • The most important slow SQL statement statistics, including average execution time, lock wait time, total number of result rows, and total number of scanned rows.
  • Count -- the number of SQL executions and percentage of the total slow log Count.
  • Time-the execution Time, including the total Time, average Time, minimum, maximum Time, and Time, as a percentage of the total slow SQL Time.
  • 95% of Time -- remove the fastest and slowest SQL statements, with a coverage rate of 95% of the SQL Execution Time.
  • Lock Time -- the waiting Time.
  • 95% of Lock -- 95% of slow SQL wait Lock time.
  • Rows sent-Number of result Rows, including average, minimum, and maximum.
  • Rows examined -- number of Rows scanned.
  • Database -- Which Database belongs.
  • Users-which user and IP address account for the percentage of SQL statements executed by all Users.
  • Query abstract -- abstract SQL statement.
  • Query sample -- SQL statement.

In addition to the above output, the official website also provides a lot of customized parameters, which is a rare and good tool.

Mysql-explain-slow-log

A perl script written by the Germans.

Http://www.willamowius.de/mysql-tools.html

Http://www.bt285.cn/content.php? Id = 1196863




Functionality flaws. We recommend that you not only print all slow logs to the screen, but also count the number of slow logs.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.