Comparison and analysis of five common MySQL slow log analysis tools _php skills

Source: Internet
Author: User
Tags php write perl script

Enable slow Log

There are two ways to enable:
1, in MY.CNF through Log-slow-queries[=file_name]
2, when the mysqld process is started, specify the--log-slow-queries[=file_name] option

Five common tools for comparison

Mysqldumpslow, Mysqlsla, Myprofi, Mysql-explain-slow-log, Mysqllogfilter

Mysqldumpslow, MySQL official provides a slow query log analysis tool. The output chart is as follows:
The main function is to count different slow SQL
Number of occurrences (count),
Execution maximum (time),
Cumulative total time-consuming (time),
The time to wait for the lock (lock),
Total number of rows sent to the client (rows),
Total number of rows scanned (rows),
The user and the SQL statement itself (the abstract format, such as Limit 1, 20 is represented by limit n,n).

Mysqlsla, Hackmysql.com launched a log analysis tool (the site also maintains the Mysqlreport, Mysqlidxchk and other more practical MySQL tools)
Overall, the function is very powerful. Data reports, very helpful to analyze the reasons for slow query, including the frequency of execution, data volume, query consumption and so on.

The format description is as follows:
Total number of queries (queries totals), after the amount of SQL (unique)
Sort the contents of the output report (sorted by)
The most significant slow SQL statistics, including the average execution time, the wait lock time, the total number of resulting rows, and the total number of rows scanned.

Count, the number of executions of SQL and the percentage of the total number of slow logs.
Time, execution times, including total time, average time, minimum, maximum time, and time as a percentage of total slow SQL time.
Of time, the fastest and slowest SQL is removed, with coverage accounting for 95% of SQL execution times.
Lock time, waiting for the lock.
of lock, 95% slow SQL wait lock time.
Rows sent, the result row statistics quantity, including average, minimum, maximum quantity.
Rows examined, the number of lines scanned.
database, which databases belong to
Users, which user, IP, percent of SQL executed by all users

Query abstract, abstract SQL statement
Query sample, SQL statement

In addition to the above output, the official also provides a lot of customization parameters, is a rare good tool.

Mysql-explain-slow-log, a Perl script written by the Germans.
Http://www.willamowius.de/mysql-tools.html


There is a flaw in functionality that not only prints all the slow log to the screen, but also counts only. Not recommended for use.
Mysql-log-filter, a profiling tool found on Google Code, offers Python and php two executable scripts.
http://code.google.com/p/mysql-log-filter/
Functionally more than the official Mysqldumpslow, the query time statistics (average, maximum, cumulative), and other features are similar to Mysqldumpslow.
Feature features in addition to statistical information, but also for the output content to do typesetting and formatting, to ensure the overall output of simplicity. Like concise statements of friends, recommended to use.
Myprofi, a pure PHP write an open source analysis tool. The project is on the sourceforge.
http://myprofi.sourceforge.net/

feature, lists the total number of slow queries and types, the number of SQL statements to be followed, and the percentage of executions and the total number of slow logs.
From the overall output style, more concise than mysql-log-filter. Eliminates a lot of unnecessary content. It is recommended for users who want to see only the SQL statements and the number of executions.

Summarize

Tools/Functions General statistical information Advanced statistical information Script Advantage
Mysqldumpslow Support does not support Perl MySQL official self-bring
Mysqlsla Support Support Perl Powerful, data reporting complete, customization ability.
Mysql-explain-slow-log Support does not support Perl No
Mysql-log-filter Support Partial support Python or PHP Without losing the function of the premise, keep the output concise
Myprofi Support does not support Php Very concise

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.