Working as a Percona Support Engineer, every day we are seeing lots of issues related to MySQL replication. One very common issue is slave lagging. There are many reasons for slave lag but one common reason is that queries are taking more time on slave then master. How to check and log those long-running queries? From MySQL 5.1, log-slow-slave-statements variable was introduced, which you can enable on slave and log slow queries. But what if you want to log slow queries on slave in earlier versions like MySQL 5.0? There is a good solution/workaround: pt-query-digest. How? …
[Read more]MySQL has a nice feature, slow query log, which allows you to log all queries that exceed a predefined about of time to execute. Peter Zaitsev first wrote about this back in 2006 – there have been a few other posts here on the MySQL Performance Blog since then (check this and this, too) but I wanted to revisit his original subject in today’s post.
Query optimization is essential for good database …
[Read more]This blog, MySQLPerformanceBlog.com, is powered by WordPress, but we never really looked into what kind of queries to MySQL are used by WordPress. So for couple months we ran a Query Analytics (part of Percona Cloud Tools) agent there, and now it is interesting to take a look on queries. Query Analytics uses reports produced by pt-query-digest, but it is quite different as it allows to see trends and dynamics of particular query, in contrast to pt-query-digest, which is just one static report.
Why looking into queries important? I gave an intro in my previous post from this series.
So Query Analytics give the report on the top queries. How to
detect which query is “bad”?
One of metrics I am typically looking into is ratio of “Rows …
Among all of the excellent events going on like YAPC, Velocity, and Percona MySQL University, we recently released Percona Toolkit 2.2.3. It’s a small update that includes the following:
- pt-online-schema-change did not handle the failure of the DROP TRIGGER statements correctly
- Created pt-agent
- pt-query-digest –output json now includes more data
The pt-online-schema-change issue had a high importance. The bug fix is bug …
[Read more]I had the chance to work on an interesting case last week, and I thought I’d share what I think is a little known goodie from Percona Toolkit for MySQL called pt-query-digest.
One customer was suffering from periods of high load on their database server, leading to degraded application performance, and sometimes even short moments of downtime. As usual with these cases, we set up pt-stalk to trigger a capture if Threads_running went above a known ‘good’ value for this workload, so we would have lots of diagnostics information to review even if we couldn’t be logged in to the server at the time the problem happened.
As I began reviewing …
[Read more]On April 3 at 10 a.m. PST, I’ll be giving a webinar titled “5 Percona Toolkit Tools for MySQL That Could Save Your Day.” In this presentation you’ll learn how to perform typical but challenging MySQL database administration tasks.
My focus will be on the following tools:
- pt-query-digest, to select the queries you should try to improve to get optimal response times
- pt-archiver, to efficiently purge purge data from huge tables
- pt-table-checksum/pt-table-sync, to check if data on replicas is in sync with data on the master
- pt-stalk, to gather data when performance problems happen randomly or are very short
- pt-online-schema-change, to run …
When you process MySQL slow query logs using pt-query-digest you can store samples of each query into query_review table and historical values for review trend analysis into query_review_history table. But it could be difficult to easily browse those tables without a good GUI tool.
For the visual browsing of tables created by pt-query-digest you may want to use some kind of web tools besides phpMyAdmin
This is a advanced, but easy to install, ui for pt-query-digest or mk-query-digest.
Main features:
* Dynamic filtering and searching of queries
* Colorized and normalized SQL syntax
* Explain the query …
You can use pt-query-digest to process a MySQL slow query log and store historical values for review trend analysis into query_review_history table. According to its official documentation you can populate many columns in that table but there are other important ones such as ‘user’, ‘host’, ‘db’ which are not included by default. I will explain how to implement this.
Also the documentation says:
Any columns not mentioned above are inspected to see if they follow a certain naming convention. The column is special if the name ends with an underscore followed by any of these MAGIC_history_cols values:
pct|avt|cnt|sum|min|max|pct_95|stddev|median|rank
…
[Read more]This guide will get you up and running with how to identify the bottleneck queries using the excellent tool pt-query-digest. You will learn how to use and analyze the output returned by pt-query-digest. You will also learn some differences between slow query logging in various MySQL versions. Later on in the post I will also show you how to make use of the extra diagnostic data available with Percona Server.
The post Profiling your slow queries using pt-query-digest and some love from Percona Server appeared first on ovais.tariq.