Linux easy to use SQL tool (D)

For you are running mysql

How performance? Whether reasonable parameter settings? Whether there is a security risk account settings?

Whether the gains?

The saying goes, it must first of its profits, on a regular basis to your MYSQL database a physical examination is an important means to ensure the safe operation of the database.

Today and share a mysql optimization tool, you can use them to perform a physical examination of your mysql, generate reports awr, let you grasp your database performance situation as a whole.

pt-qurey-digest

pt-query-digest main function is from the log, process list and tcpdump MySQL query analysis

1. Install

With specific reference to Linux easy to use tool for SQL (c)

2. Use

pt-query-digest is mainly used to analyze the log mysql slow, compared with mysqldumpshow tools, analysis tools py-query_digest more specific and better.

终端执行:pt-query-digest /var/lib/mysql/slowtest-slow.log

3. Common usage analysis

1) direct analysis of slow query file:

pt-query-digest /var/lib/mysql/slowtest-slow.log > slow_report.log

2) analytical queries within the last 12 hours:

pt-query-digest --since=12h /var/lib/mysql/slowtest-slow.log > slow_report2.log

3) analytical queries within a specified time range:

pt-query-digest /var/lib/mysql/slowtest-slow.log --since '2020-01-07 09:30:00' --until '2020-01-07 10:00:00'> > slow_report3.log

4) analysis of slow query contains only a select statement:

pt-query-digest --filter '$event->{fingerprint} =~ m/^select/i' /var/lib/mysql/slowtest-slow.log> slow_report4.log

5) for a user's slow query:

pt-query-digest --filter '($event->{user} || "") =~ m/^root/i' /var/lib/mysql/slowtest-slow.log> slow_report5.log

6) to query all full table scan or full join the manchaxun:

pt-query-digest --filter '(($event->{Full_scan} || "") eq "yes") ||(($event->{Full_join} || "") eq "yes")' /var/lib/mysql/slowtest-slow.log> slow_report6.log

4. Analysis Report

Part 1: General statistics Overall: Total number of queries Time range: Time range query execution unique: the number of unique queries that the query conditions after parameterization, a total of how many different queries total: Total min: minimum max : Max avg: average 95%: all of the values ​​in ascending order, located the 95% of the number, this number is generally the most valuable median: median, all of the values ​​in ascending order, location in the middle of that number .

Part II: inquiry packet statistics Rank: Rank all statements, query time by default in descending order, specified by -order-by Query ID: ID statement (remove extra spaces and text characters, calculated hash value) Response: Total response time time: the query in this analysis proportion of the total time calls: execution times, i.e., this analysis a total of how many of this type of query R / Call: the average response time of each execution V / M : response time Variance-to-mean ratio of Item: query object.

Part III: Detailed statistical results of each query ID: ID number of the query, the Query ID, and corresponding FIG Databases: database name Users: number (proportion) of each user to perform Query_time distribution: the distribution of the query time, reflect the length interval accounting. Tables: tables involved in the query to Explain: SQL statement.

Daily share a handy gadget, hope to have better resources can be a lot of small partners share exchange, thanks.

Released seven original articles · won praise 7 · views 262

Guess you like

Origin blog.csdn.net/weixin_44145894/article/details/105149333