SlideShare a Scribd company logo
1 of 121
Download to read offline
Practical Performance Tuning 
using Digested SQL Logs	

Bob Burgess
Salesforce Marketing Cloud
Who?	

!   Database Architect	

!   Salesforce Marketing Cloud (Radian6  Buddy Media stack)
Why?	

!   I can’t be the only one
Talking about today…	

!   Slow database: the problem  the solution	

!   What is the MySQL “Slow Log”?	

!   Making sense of log contents	

!   Interpreting the digested log	

!   Tuning examples
Slow Database: the problem  the solution
The Problem	

!   Slow database. Why?	

!   Long-running queries	

!   Small “fast” queries (numerous  not tuned)	

!   Small “fast” queries (tuned but extremely numerous)
The Solution	

!   Watch everything then analyze	

!   Catch all queries, even the “fast” queries	

!   Look at total time spent on each query	

!   Attack them from the top, down
Capture Everything	

!   “Slow” Log	

!   Detailed	

!   Too detailed?
What is the MySQL “Slow Log”?
Slow Log: Purpose	

!   Log all queries	

!   Time threshold	

!   Capture information about each query	

• Execution time	

• Row counts	

• User  Host	

• Others
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Contents	

# Time: 150329 9:52:13
# User@Host: root[root] @ localhost [] Id: 1
# Schema: sakila Last_errno: 0 Killed: 0
# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
Slow Log: Configuration	

!   set global long_query_time = 0;
!   threshold execution time for inclusion in slow log
Slow Log: Configuration	

!   set global slow_query_log_file = '/path/to/slow.log';
!   location of the slow log file
Slow Log: Configuration	

!   set global log_slow_verbosity = 'microtime';
!   what to include in the slow log file	

!   microtime	

!   innodb	

!   query_plan	

!   profiling
Slow Log: Configuration	

!   set global slow_query_log_use_global_control =
'long_query_time, log_slow_verbosity';
!   make slow log configuration changes apply to all sessions, 
including open sessions
Slow Log: Configuration	

!   set global log_slow_slave_statements = 1;
!   include replicated SQL in the slow log
Slow Log: Configuration	

!   set global slow_query_log = 1;
!   turn on the slow log!	

!   High activity / slow disk	

!   General overhead
Slow Log with different MySQL versions
Slow-Log in Stock 5.1 / 5.5 / 5.6	

!   set global slow_query_log_file = '/path/to/slow.log';
set global long_query_time=0;
set global slow_query_log=1;
!   Logs only for sessions created after logging starts
Slow-Log in Percona 5.1 / 5.5 / 5.6	

!   set global slow_query_log_file = '/path/to/slow.log';
set global long_query_time=0;
set global slow_query_log=1;
!   Logs only for sessions created after logging starts
Slow-Log in Percona 5.1	

!   set global slow_query_log_file = '/path/to/slow.log';
set global long_query_time=0;
set global log_slow_verbosity='microtime,innodb';
set global use_global_log_slow_control=1;
set global log_slow_slave_statements=1;
set global slow_query_log=1;
!   Logs all sessions (and include innodb info  slave SQL)
Slow-Log in Percona 5.5 / 5.6	

!   set global slow_query_log_file = '/path/to/slow.log';
set global long_query_time=0;
set global log_slow_verbosity='microtime,innodb';
set global slow_query_log_use_global_control=1;
set global log_slow_slave_statements=1;
set global slow_query_log=1;
!   Logs all sessions (and include innodb info  slave SQL)
5.1 / 5.5 / 5.6
Stock	

5.1
Percona	

5.5 / 5.6
Percona	

long_query_time	

 yes	

 yes	

 yes	

slow_query_log_file	

 yes	

 yes	

 yes	

log_slow_verbosity	

 no: “microtime” only	

 yes	

 yes	

slow_query_log
_use_global_control	

no: session only	

“use_global_log
_slow_control”	

yes	

log_slow_slave
_statements	

no	

 yes	

 yes
5.1 / 5.5 / 5.6
Stock	

5.1
Percona	

5.5 / 5.6
Percona	

long_query_time	

 yes	

 yes	

 yes	

slow_query_log_file	

 yes	

 yes	

 yes	

log_slow_verbosity	

 no: “microtime” only	

 yes	

 yes	

slow_query_log
_use_global_control	

no: session only	

“use_global_log
_slow_control”	

yes	

log_slow_slave
_statements	

no	

 yes	

 yes
5.1 / 5.5 / 5.6
Stock	

5.1
Percona	

5.5 / 5.6
Percona	

long_query_time	

 yes	

 yes	

 yes	

slow_query_log_file	

 yes	

 yes	

 yes	

log_slow_verbosity	

 no: “microtime” only	

 yes	

 yes	

slow_query_log
_use_global_control	

no: session only	

“use_global_log
_slow_control”	

yes	

log_slow_slave
_statements	

no	

 yes	

 yes
5.1 / 5.5 / 5.6
Stock	

5.1
Percona	

5.5 / 5.6
Percona	

long_query_time	

 yes	

 yes	

 yes	

slow_query_log_file	

 yes	

 yes	

 yes	

log_slow_verbosity	

 no: “microtime” only	

 yes	

 yes	

slow_query_log
_use_global_control	

no: session only	

“use_global_log
_slow_control”	

yes	

log_slow_slave
_statements	

no	

 yes	

 yes
Making Sense of Log Contents	

!   Millions of pieces of data	

!   grep | awk | sort | uniq -c
!   pt-query-digest	

!   created by Baron Schwartz	

!   primarily developed by him and Daniel Nichter
pt-query-digest	

!   Aggregates log entry data by query fingerprint	

!   Sorts output by whatever’s important to you
pt-query-digest: query fingerprint	

select * from actor where first_name='JOHN';
SELECT /* my query */ last_name From actor where first_name = 'Bob';
select * from actor where first_name=?

select 50, last_name from actor 

where first_name='JOHN' and last_name in ('SMITH', 'JONES');
select ?, last_name from actor where first_name=? and last_name in(?+)
pt-query-digest: Output	

# 1825.5s user time, 19.6s system time, 526.79M rss, 677.20M vsz
# Current date: Tue Mar 10 12:16:58 2015
# Hostname: db1234
# Files: slow.log.db5678
# Overall: 6.36M total, 775 unique, 10.90k QPS, 5.54x concurrency
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Query
execution time
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Time before
query executes
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Rows returned
to the client
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Rows scanned
for selects
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Rows changed
by ins/upd/del
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Rows read to
process ins/upd/
del
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Size of result
set
pt-query-digest: Output	

# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute total min max avg 95% stddev median
# ============ ======= ======= ======= ======= ======= ======= =======
# Exec time 3228s 1us 79s 507us 657us 52ms 131us
# Lock time 303s 0 2s 47us 125us 1ms 30us
# Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99
# Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Rows affecte 128.30k 0 77 0.02 0 0.17 0
# Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99
# Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02
# Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
Size of incoming
SQL
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Rank in
specified sort
order
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Hash of query
fingerprint
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Total time
spent
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
How many
times this SQL
ran
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Mean response
time per call
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Variance to Mean ratio
(indicates spread of values)
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Command
and tables
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
Rank in sort
order
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
How many
per second
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
Query ID
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
Percent of
Total
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
Total this
query
pt-query-digest: Output per Query	

# Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373
# Scores: V/M = 0.03
# Time range: 2015-03-10 11:34:01 to 11:43:44
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 8 547909
# Exec time 3 119s 100us 922ms 217us 424us 2ms 159us
# Lock time 10 31s 18us 10ms 56us 131us 97us 36us
# Rows sent 0 535.07k 1 1 1 1 0 1
# Rows examine 0 535.07k 1 1 1 1 0 1
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 535.07k 1 1 1 1 0 1
# Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k
# Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
Stats
pt-query-digest: Output per Query	

# String:
# Databases sphere
# Hosts dm1234 (90486/36%), dm2345 (79213/24%), ap3456 (77959/23%)
# Last errno 0
# Users appuser01 (478323/87%), appuser02 (64465/11%), appuser03(5049/0%)
pt-query-digest: Output per Query	

# Query_time distribution
# 1us
# 10us ##
# 100us ################################################################
# 1ms ####
# 10ms #
# 100ms #
# 1s
# 10s+
pt-query-digest: Output per Query	

# Tables
# SHOW TABLE STATUS FROM `sphere` LIKE 'ApplicationUser'G
# SHOW CREATE TABLE `sphere`.`ApplicationUser`G
# SHOW TABLE STATUS FROM `sphere` LIKE 'Client'G
# SHOW CREATE TABLE `sphere`.`Client`G
# EXPLAIN /*!50100 PARTITIONS*/
SELECT au.*, c.active, c.clientEndDate FROM ApplicationUser au JOIN Client c ON
au.clientId = c.clientId WHERE userId = 48954G
pt-query-digest: Useful Switches	

!   --limit	

!   “Top-n” limit	

!   Percent and/or number of results	

!   --limit 95%:20
!   --limit 5
!   --limit 10%
pt-query-digest: Useful Switches	

!   --show-all	

!   Show all values in lists, not just what fits on one line
pt-query-digest: Useful Switches	

!   --order-by	

!   Specify how to sort the output	

!   Parameter is {metric}:{function}	

!   --order-by Query_time:sum (default)
!   --order-by Bytes_sent:sum (interface saturation?)
!   --order-by Rows_examined:sum (Find table scans)
!   --order-by Query-time:cnt (find high QPS)
pt-query-digest: Useful Switches	

!   --explain	

!   Explain each query	

!   Specify where to connect for the Explain Plan queries	

!   --explain h=myServer,P=3306,u=myUser,p=secret
Generating Log Digests	

First: Get pt-query-digest	

	

wget percona.com/get/pt-query-digest
chmod +x pt-query-digest
Generating Log Digests	

Then: Enable the slow log for a limited time	

	

mysql –e'set global {all the settings from earlier}'
mysql –e'set global slow_query_log=1'
sleep 60
mysql –e'set global slow_query_log=0'
Generating Log Digests	

Digest the resulting log…	

	

./pt-query-digest /path/to/slow.log digest.txt
Generating Log Digests (Periodic)	

For 10 minutes:	

•  Enable the slow log	

•  Wait 30 seconds	

•  Disable the slow log	

•  Wait 30 seconds	

	

Then…	

pt-query-digest --limit 5 --explain h=…,P=…
/path/to/slow.log digest.txt
Generating Log Digests (Emergency)	

•  Enable the slow log	

•  Wait 30 seconds	

•  Disable the slow log	

	

Then…	

pt-query-digest --show-all /path/to/slow.log digest.txt
Interpreting Digested Logs	

!   Most important metric: total execution time	

4 s	

 100 ms
Interpreting Digested Logs	

!   Most important metric: total execution time	

4 s	

 8 s
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
pt-query-digest: Output	

# Profile
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== =============== ======= ====== ====== ====================================================
# 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions
# 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute
# 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client
# 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter
# 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT
# MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
Single Most
Important Metric	

THEN look at each query, starting from the top
Interpreting Digested Logs (Steps)	

!   Generate Digest, sorted by total execution time per query	

! Start with Query #1; work your way down	

!   Don’t get distracted by other queries in the list, or not in the list	

! Ignore the actual SQL until you start tuning
Interpreting Digested Logs (Steps)	

Two main reasons for appearing on the list:	

!   High queries-per-second (high enough that fast queries are making the list)	

!   Expensive query (not running often, but when they do…)	

And also…	

!   “Sort of expensive” — fast enough, except when we run a lot of them
Interpreting Digested Logs (examples)	

# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============== ======= ======= ====== ==================================
# 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes
# 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants
# 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException
# 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup
FilterQuery
Interpreting Digested Logs (example 1)	

Reality-based…
Interpreting Digested Logs (example 1)	

# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============== ======= ======= ====== ==================================
# 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes
# 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants
# 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException
# 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup
FilterQuery
# Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036
# Scores: V/M = 2.40
# Time range: 2015-03-29 09:55:10 to 10:04:31
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 255
# Exec time 25 607s 8ms 6s 2s 5s 2s 2s
# Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us
# Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17
# Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k
# Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34
Interpreting Digested Logs (example 1)
# Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036
# Scores: V/M = 2.40
# Time range: 2015-03-29 09:55:10 to 10:04:31
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 255
# Exec time 25 607s 8ms 6s 2s 5s 2s 2s
# Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us
# Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17
# Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k
# Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34
Interpreting Digested Logs (example 1)
# Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036
# Scores: V/M = 2.40
# Time range: 2015-03-29 09:55:10 to 10:04:31
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 255
# Exec time 25 607s 8ms 6s 2s 5s 2s 2s
# Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us
# Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17
# Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k
# Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34
Interpreting Digested Logs (example 1)
# Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036
# Scores: V/M = 2.40
# Time range: 2015-03-29 09:55:10 to 10:04:31
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 255
# Exec time 25 607s 8ms 6s 2s 5s 2s 2s
# Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us
# Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17
# Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k
# Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k
# Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34
Interpreting Digested Logs (example 1)
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms #
# 10ms ##################################################
# 100ms #######
# 1s ################################################################
# 10s+
Interpreting Digested Logs (example 1)
Interpreting Digested Logs (example 1)	

select userId, clientId, userAttributeTypeId, value from UserAttributes
where clientId = 23495 and userAttributeTypeId = 1G
# *************************** 1. row ***************************
# id: 1
# select_type: SIMPLE
# table: UserAttributes
# partitions: NULL
# type: ALL
# possible_keys: NULL
# key: NULL
# key_len: NULL
# ref: NULL
# rows: 11270
# Extra: Using where
Interpreting Digested Logs (example 1)	

select userId, clientId, userAttributeTypeId, value from UserAttributes
where clientId = 23495 and userAttributeTypeId = 1G
# *************************** 1. row ***************************
# id: 1
# select_type: SIMPLE
# table: UserAttributes
# partitions: NULL
# type: ALL
# possible_keys: NULL
# key: NULL
# key_len: NULL
# ref: NULL
# rows: 11270
# Extra: Using where
Interpreting Digested Logs (example 1)	

select userId, clientId, userAttributeTypeId, value from UserAttributes
where clientId = 23495 and userAttributeTypeId = 1G
# *************************** 1. row ***************************
# id: 1
# select_type: SIMPLE
# table: UserAttributes
# partitions: NULL
# type: ALL
# possible_keys: NULL
# key: NULL
# key_len: NULL
# ref: NULL
# rows: 11270
# Extra: Using where
New index required.
Interpreting Digested Logs (example 2)	

Reality-based…
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============== ======= ======= ====== ==================================
# 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes
# 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants
# 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException
# 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup
FilterQuery
Interpreting Digested Logs (example 2)
# Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570
# Scores: V/M = 0.24
# Time range: 2015-03-29 09:55:08 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 1346
# Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms
# Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us
# Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83
# Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84
# Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k
Interpreting Digested Logs (example 2)
# Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570
# Scores: V/M = 0.24
# Time range: 2015-03-29 09:55:08 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 1346
# Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms
# Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us
# Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83
# Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84
# Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k
Interpreting Digested Logs (example 2)
# Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570
# Scores: V/M = 0.24
# Time range: 2015-03-29 09:55:08 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 1346
# Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms
# Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us
# Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83
# Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84
# Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k
Interpreting Digested Logs (example 2)
# Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570
# Scores: V/M = 0.24
# Time range: 2015-03-29 09:55:08 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 1346
# Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms
# Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us
# Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83
# Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k
# Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84
# Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k
Interpreting Digested Logs (example 2)
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms #############################
# 100ms ################################################################
# 1s #
# 10s+
Interpreting Digested Logs (example 2)
Index problem.	

Interpreting Digested Logs (example 2)
Interpreting Digested Logs (example 3)	

Reality-based…
# Rank Query ID Response time Calls R/Call V/M Item
# ==== ================== ============== ======= ======= ====== ==================================
# 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes
# 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants
# 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException
# 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup
FilterQuery
Interpreting Digested Logs (example 3)
# Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949
# Scores: V/M = 9.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 15175
# Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us
# Lock time 0 704ms 19us 11ms 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0
# Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40
# Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 3)
# Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949
# Scores: V/M = 9.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 15175
# Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us
# Lock time 0 704ms 19us 11ms 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0
# Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40
# Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 3)
# Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949
# Scores: V/M = 9.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 15175
# Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us
# Lock time 0 704ms 19us 11ms 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0
# Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0
# Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40
# Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 3)
# Query_time distribution
# 1us
# 10us
# 100us ################################################################
# 1ms ###
# 10ms #
# 100ms #
# 1s #
# 10s+ #
Interpreting Digested Logs (example 3)
select blogPostId, postStatusId from PostStatusException where topicFilterId in (560938,549993)
and publishedDate between '2014-05-02 22:34:22' and '2015-03-29 10:02:12’G
# *************************** 1. row ***************************
# id: 1
# select_type: SIMPLE
# table: PostStatusException
# partitions: NULL
# type: range
# possible_keys: PRIMARY,topicFilterPublishedDate
# key: PRIMARY
# key_len: 4
# ref: NULL
# rows: 13285286
# Extra: Using where
Interpreting Digested Logs (example 3)
•  Acceptable index in this case.!
•  For this query, some predicates naturally return large result sets.!
Interpreting Digested Logs (example 3)
Interpreting Digested Logs (example 4)	

Not reality-based…	

But sometimes happens!
Interpreting Digested Logs (example 4)	

# Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949
# Scores: V/M = 1.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 915175
# Exec time 26 205s 105us 802us 224us 118us 99us 198us
# Lock time 0 704ms 19us 91us 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0
# Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0
# Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40
# Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 4)	

# Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949
# Scores: V/M = 1.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 915175
# Exec time 26 205s 105us 802us 224us 118us 99us 198us
# Lock time 0 704ms 19us 91us 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0
# Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0
# Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40
# Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 4)	

# Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949
# Scores: V/M = 0.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 915175
# Exec time 26 205s 105us 802us 224us 118us 99us 198us
# Lock time 0 704ms 19us 91us 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0
# Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0
# Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40
# Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 4)	

# Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949
# Scores: V/M = 0.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 915175
# Exec time 26 205s 105us 802us 224us 118us 99us 198us
# Lock time 0 704ms 19us 91us 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0
# Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0
# Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40
# Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (example 4)	

# Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949
# Scores: V/M = 0.27
# Time range: 2015-03-29 09:55:01 to 10:04:34
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 0 915175
# Exec time 26 205s 105us 802us 224us 118us 99us 198us
# Lock time 0 704ms 19us 91us 46us 57us 232us 26us
# Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0
# Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0
# Rows affecte 0 0 0 0 0 0 0 0
# Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0
# Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40
# Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
Interpreting Digested Logs (other cases)	

# Databases schema1 (813422/89%), schema2 (101753/11%)
# Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%)
# Last errno 0
# Users user1 (813422/89%), user2 (101753/11%)
Interpreting Digested Logs (other cases)	

# Databases schema1 (813422/89%), schema2 (101753/11%)
# Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%)
# Last errno 0
# Users user1 (813422/89%), user2 (101753/11%)
Interpreting Digested Logs (other cases)	

# Databases schema1 (813422/89%), schema2 (101753/11%)
# Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%)
# Last errno 0
# Users user1 (813422/89%), user2 (101753/11%)
Interpreting Digested Logs (other cases)	

# Databases schema1 (813422/89%), schema2 (101753/11%)
# Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%)
# Last errno 0
# Users user1 (813422/89%), user2 (101753/11%)
Talk to developers, verify logic	

Talk to Operations, verify traffic pattern
Trending	

!   Spreadsheet	

!   Set up database to accept pt-query-digest output 
(see --review and --history switches)
Other Slow Log Analyses	

Finding Outliers!
!   Reports of a slow query that doesn’t make it in the log digest	

# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
!   Dump out all access times from the slow log for this query:	

grep -B 3 'select * from actor where first_name' slow.log | 
grep Query | cut -f3 -d' ' | tr -d . file
Other Slow Log Analyses	

Finding Outliers!
!   Reports of a slow query that doesn’t make it in the log digest	

# Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0
# Bytes_sent: 267
SET timestamp=1427633533;
select * from actor where first_name='JOHN';
!   Go right nuts: Dump out all access times from the slow log for this query, including timestamps:	

grep -B 3 'select * from actor where first_name' slow.log | 
grep -E 'Query|timestamp' | cut -f2,3 -d' ' | tr '=' ' ' | 
(while read Q T; do read TS; echo $TS $T; done) | 
cut -f2,3 -d' ' | tr -d ';' file
Extra Reading / Resources	

!   Percona Docs	

! http://www.percona.com/doc/percona-server/5.5/diagnostics/
slow_extended_55.html	

! http://www.percona.com/doc/percona-server/5.1/diagnostics/slow_extended.html?
id=percona-server:features:slow_extended_51	

! http://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html	

!   MySQL Docs	

! http://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html	

!   Slides, and script to safely do periodic slow log digests	

! bit.ly/BobBurgessPercona2015
Thank You!	

Bob Burgess	

rburgess@salesforce.com	

bit.ly/BobBurgessPercona2015	

	

Please fill out the session evaluation!

More Related Content

What's hot

High Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and SolutionsHigh Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and SolutionsYinghai Lu
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!Jeff Anderson
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackAustralian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackMatt Ray
 
How to Fail at Kafka
How to Fail at KafkaHow to Fail at Kafka
How to Fail at Kafkaconfluent
 
Load Balancing with Nginx
Load Balancing with NginxLoad Balancing with Nginx
Load Balancing with NginxMarian Marinov
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Fastly
 
London devops logging
London devops loggingLondon devops logging
London devops loggingTomas Doran
 
Odoo Online platform: architecture and challenges
Odoo Online platform: architecture and challengesOdoo Online platform: architecture and challenges
Odoo Online platform: architecture and challengesOdoo
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on NetscalerMark Hillick
 
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltStack
 
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Ontico
 
Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Trygve Vea
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014Amazon Web Services
 
etcd based PostgreSQL HA Cluster
etcd based PostgreSQL HA Clusteretcd based PostgreSQL HA Cluster
etcd based PostgreSQL HA Clusterwinsletts
 
Massively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHPMassively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHPDemin Yin
 
How to tune Kafka® for production
How to tune Kafka® for productionHow to tune Kafka® for production
How to tune Kafka® for productionconfluent
 
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...Nagios
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)Ontico
 

What's hot (20)

High Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and SolutionsHigh Performance Erlang - Pitfalls and Solutions
High Performance Erlang - Pitfalls and Solutions
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStackAustralian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStack
 
How to Fail at Kafka
How to Fail at KafkaHow to Fail at Kafka
How to Fail at Kafka
 
Load Balancing with Nginx
Load Balancing with NginxLoad Balancing with Nginx
Load Balancing with Nginx
 
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
Mitigating Security Threats with Fastly - Joe Williams at Fastly Altitude 2015
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Tuning Solr for Logs
Tuning Solr for LogsTuning Solr for Logs
Tuning Solr for Logs
 
Odoo Online platform: architecture and challenges
Odoo Online platform: architecture and challengesOdoo Online platform: architecture and challenges
Odoo Online platform: architecture and challenges
 
Integrated Cache on Netscaler
Integrated Cache on NetscalerIntegrated Cache on Netscaler
Integrated Cache on Netscaler
 
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStackSaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
SaltConf14 - Oz Akan, Rackspace - Deploying OpenStack Marconi with SaltStack
 
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
Testing applications with traffic control in containers / Alban Crequy (Kinvolk)
 
Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
 
etcd based PostgreSQL HA Cluster
etcd based PostgreSQL HA Clusteretcd based PostgreSQL HA Cluster
etcd based PostgreSQL HA Cluster
 
Massively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHPMassively Scaled High Performance Web Services with PHP
Massively Scaled High Performance Web Services with PHP
 
How to tune Kafka® for production
How to tune Kafka® for productionHow to tune Kafka® for production
How to tune Kafka® for production
 
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
 
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)MySQL Replication — Advanced Features / Петр Зайцев (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
 

Viewers also liked

Electro chemical cells
Electro chemical cellsElectro chemical cells
Electro chemical cellsNauman Khan
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShareSlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShareSlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

Viewers also liked (13)

Islam in spain
Islam in spainIslam in spain
Islam in spain
 
Muslim Rule in Spain
Muslim Rule in SpainMuslim Rule in Spain
Muslim Rule in Spain
 
Electro chemical cells
Electro chemical cellsElectro chemical cells
Electro chemical cells
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
You Suck At PowerPoint!
You Suck At PowerPoint!You Suck At PowerPoint!
You Suck At PowerPoint!
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Similar to MySQL Tuning using digested slow-logs

MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveSveta Smirnova
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writerEnkitec
 
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails AppSrijan Technologies
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writerKyle Hailey
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010wremes
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptChien Chung Shen
 
Collaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportCollaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportAlfredo Krieg
 
Easy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingEasy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingBob Burgess
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикAgnislav Onufrijchuk
 
Building a Distributed Message Log from Scratch
Building a Distributed Message Log from ScratchBuilding a Distributed Message Log from Scratch
Building a Distributed Message Log from ScratchTyler Treat
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyTim Bunce
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1Chien Chung Shen
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWRpasalapudi
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache KafkaShiao-An Yuan
 
Tracing the Breadcrumbs: Apache Spark Workload Diagnostics
Tracing the Breadcrumbs: Apache Spark Workload DiagnosticsTracing the Breadcrumbs: Apache Spark Workload Diagnostics
Tracing the Breadcrumbs: Apache Spark Workload DiagnosticsDatabricks
 
AWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptAWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptbugzbinny
 

Similar to MySQL Tuning using digested slow-logs (20)

MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writer
 
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writer
 
OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010OSSEC @ ISSA Jan 21st 2010
OSSEC @ ISSA Jan 21st 2010
 
Oracle Database Performance Tuning Concept
Oracle Database Performance Tuning ConceptOracle Database Performance Tuning Concept
Oracle Database Performance Tuning Concept
 
Using AWR for IO Subsystem Analysis
Using AWR for IO Subsystem AnalysisUsing AWR for IO Subsystem Analysis
Using AWR for IO Subsystem Analysis
 
Collaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR ReportCollaborate 2019 - How to Understand an AWR Report
Collaborate 2019 - How to Understand an AWR Report
 
Easy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and TroubleshootingEasy MySQL Replication Setup and Troubleshooting
Easy MySQL Replication Setup and Troubleshooting
 
Оптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчикОптимизация MySQL. Что должен знать каждый разработчик
Оптимизация MySQL. Что должен знать каждый разработчик
 
Building a Distributed Message Log from Scratch
Building a Distributed Message Log from ScratchBuilding a Distributed Message Log from Scratch
Building a Distributed Message Log from Scratch
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1
 
Analyzing and Interpreting AWR
Analyzing and Interpreting AWRAnalyzing and Interpreting AWR
Analyzing and Interpreting AWR
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
RubyKaigi 2014: ServerEngine
RubyKaigi 2014: ServerEngineRubyKaigi 2014: ServerEngine
RubyKaigi 2014: ServerEngine
 
Tracing the Breadcrumbs: Apache Spark Workload Diagnostics
Tracing the Breadcrumbs: Apache Spark Workload DiagnosticsTracing the Breadcrumbs: Apache Spark Workload Diagnostics
Tracing the Breadcrumbs: Apache Spark Workload Diagnostics
 
Hotsos Advanced Linux Tools
Hotsos Advanced Linux ToolsHotsos Advanced Linux Tools
Hotsos Advanced Linux Tools
 
AWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptAWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.ppt
 

Recently uploaded

High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...soniya singh
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...shivangimorya083
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 

Recently uploaded (20)

High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
High Class Call Girls Noida Sector 39 Aarushi 🔝8264348440🔝 Independent Escort...
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
Full night 🥵 Call Girls Delhi New Friends Colony {9711199171} Sanya Reddy ✌️o...
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 

MySQL Tuning using digested slow-logs

  • 1. Practical Performance Tuning using Digested SQL Logs Bob Burgess Salesforce Marketing Cloud
  • 2. Who? !   Database Architect !   Salesforce Marketing Cloud (Radian6 Buddy Media stack)
  • 3. Why? !   I can’t be the only one
  • 4. Talking about today… !   Slow database: the problem the solution !   What is the MySQL “Slow Log”? !   Making sense of log contents !   Interpreting the digested log !   Tuning examples
  • 5. Slow Database: the problem the solution
  • 6. The Problem !   Slow database. Why? !   Long-running queries !   Small “fast” queries (numerous not tuned) !   Small “fast” queries (tuned but extremely numerous)
  • 7. The Solution !   Watch everything then analyze !   Catch all queries, even the “fast” queries !   Look at total time spent on each query !   Attack them from the top, down
  • 8. Capture Everything !   “Slow” Log !   Detailed !   Too detailed?
  • 9. What is the MySQL “Slow Log”?
  • 10. Slow Log: Purpose !   Log all queries !   Time threshold !   Capture information about each query • Execution time • Row counts • User Host • Others
  • 11. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 12. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 13. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 14. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 15. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 16. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 17. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 18. Slow Log: Contents # Time: 150329 9:52:13 # User@Host: root[root] @ localhost [] Id: 1 # Schema: sakila Last_errno: 0 Killed: 0 # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN';
  • 19. Slow Log: Configuration !   set global long_query_time = 0; !   threshold execution time for inclusion in slow log
  • 20. Slow Log: Configuration !   set global slow_query_log_file = '/path/to/slow.log'; !   location of the slow log file
  • 21. Slow Log: Configuration !   set global log_slow_verbosity = 'microtime'; !   what to include in the slow log file !   microtime !   innodb !   query_plan !   profiling
  • 22. Slow Log: Configuration !   set global slow_query_log_use_global_control = 'long_query_time, log_slow_verbosity'; !   make slow log configuration changes apply to all sessions, including open sessions
  • 23. Slow Log: Configuration !   set global log_slow_slave_statements = 1; !   include replicated SQL in the slow log
  • 24. Slow Log: Configuration !   set global slow_query_log = 1; !   turn on the slow log! !   High activity / slow disk !   General overhead
  • 25. Slow Log with different MySQL versions
  • 26. Slow-Log in Stock 5.1 / 5.5 / 5.6 !   set global slow_query_log_file = '/path/to/slow.log'; set global long_query_time=0; set global slow_query_log=1; !   Logs only for sessions created after logging starts
  • 27. Slow-Log in Percona 5.1 / 5.5 / 5.6 !   set global slow_query_log_file = '/path/to/slow.log'; set global long_query_time=0; set global slow_query_log=1; !   Logs only for sessions created after logging starts
  • 28. Slow-Log in Percona 5.1 !   set global slow_query_log_file = '/path/to/slow.log'; set global long_query_time=0; set global log_slow_verbosity='microtime,innodb'; set global use_global_log_slow_control=1; set global log_slow_slave_statements=1; set global slow_query_log=1; !   Logs all sessions (and include innodb info slave SQL)
  • 29. Slow-Log in Percona 5.5 / 5.6 !   set global slow_query_log_file = '/path/to/slow.log'; set global long_query_time=0; set global log_slow_verbosity='microtime,innodb'; set global slow_query_log_use_global_control=1; set global log_slow_slave_statements=1; set global slow_query_log=1; !   Logs all sessions (and include innodb info slave SQL)
  • 30. 5.1 / 5.5 / 5.6 Stock 5.1 Percona 5.5 / 5.6 Percona long_query_time yes yes yes slow_query_log_file yes yes yes log_slow_verbosity no: “microtime” only yes yes slow_query_log _use_global_control no: session only “use_global_log _slow_control” yes log_slow_slave _statements no yes yes
  • 31. 5.1 / 5.5 / 5.6 Stock 5.1 Percona 5.5 / 5.6 Percona long_query_time yes yes yes slow_query_log_file yes yes yes log_slow_verbosity no: “microtime” only yes yes slow_query_log _use_global_control no: session only “use_global_log _slow_control” yes log_slow_slave _statements no yes yes
  • 32. 5.1 / 5.5 / 5.6 Stock 5.1 Percona 5.5 / 5.6 Percona long_query_time yes yes yes slow_query_log_file yes yes yes log_slow_verbosity no: “microtime” only yes yes slow_query_log _use_global_control no: session only “use_global_log _slow_control” yes log_slow_slave _statements no yes yes
  • 33. 5.1 / 5.5 / 5.6 Stock 5.1 Percona 5.5 / 5.6 Percona long_query_time yes yes yes slow_query_log_file yes yes yes log_slow_verbosity no: “microtime” only yes yes slow_query_log _use_global_control no: session only “use_global_log _slow_control” yes log_slow_slave _statements no yes yes
  • 34. Making Sense of Log Contents !   Millions of pieces of data !   grep | awk | sort | uniq -c !   pt-query-digest !   created by Baron Schwartz !   primarily developed by him and Daniel Nichter
  • 35. pt-query-digest !   Aggregates log entry data by query fingerprint !   Sorts output by whatever’s important to you
  • 36. pt-query-digest: query fingerprint select * from actor where first_name='JOHN'; SELECT /* my query */ last_name From actor where first_name = 'Bob'; select * from actor where first_name=? select 50, last_name from actor 
 where first_name='JOHN' and last_name in ('SMITH', 'JONES'); select ?, last_name from actor where first_name=? and last_name in(?+)
  • 37. pt-query-digest: Output # 1825.5s user time, 19.6s system time, 526.79M rss, 677.20M vsz # Current date: Tue Mar 10 12:16:58 2015 # Hostname: db1234 # Files: slow.log.db5678 # Overall: 6.36M total, 775 unique, 10.90k QPS, 5.54x concurrency
  • 38. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51
  • 39. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Query execution time
  • 40. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Time before query executes
  • 41. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Rows returned to the client
  • 42. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Rows scanned for selects
  • 43. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Rows changed by ins/upd/del
  • 44. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Rows read to process ins/upd/ del
  • 45. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Size of result set
  • 46. pt-query-digest: Output # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute total min max avg 95% stddev median # ============ ======= ======= ======= ======= ======= ======= ======= # Exec time 3228s 1us 79s 507us 657us 52ms 131us # Lock time 303s 0 2s 47us 125us 1ms 30us # Rows sent 173.14M 0 7.27M 28.56 20.43 8.25k 0.99 # Rows examine 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Rows affecte 128.30k 0 77 0.02 0 0.17 0 # Rows read 781.43M 0 11.46M 128.90 59.77 15.43k 0.99 # Bytes sent 11.60G 0 414.78M 1.91k 2.62k 358.51k 537.02 # Query size 1.48G 6 121.50k 250.43 719.66 363.95 166.51 Size of incoming SQL
  • 47. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
  • 48. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Rank in specified sort order
  • 49. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Hash of query fingerprint
  • 50. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Total time spent
  • 51. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS How many times this SQL ran
  • 52. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Mean response time per call
  • 53. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Variance to Mean ratio (indicates spread of values)
  • 54. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Command and tables
  • 55. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84
  • 56. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 Rank in sort order
  • 57. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 How many per second
  • 58. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 Query ID
  • 59. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 Percent of Total
  • 60. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 Total this query
  • 61. pt-query-digest: Output per Query # Query 3: 939.81 QPS, 0.20x concurrency, ID 0x4A106EF2450AEAC1 at byte 2946778373 # Scores: V/M = 0.03 # Time range: 2015-03-10 11:34:01 to 11:43:44 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 8 547909 # Exec time 3 119s 100us 922ms 217us 424us 2ms 159us # Lock time 10 31s 18us 10ms 56us 131us 97us 36us # Rows sent 0 535.07k 1 1 1 1 0 1 # Rows examine 0 535.07k 1 1 1 1 0 1 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 535.07k 1 1 1 1 0 1 # Bytes sent 12 1.41G 2.62k 2.89k 2.71k 2.62k 6.83 2.62k # Query size 5 78.87M 148 176 150.94 151.03 2.37 143.84 Stats
  • 62. pt-query-digest: Output per Query # String: # Databases sphere # Hosts dm1234 (90486/36%), dm2345 (79213/24%), ap3456 (77959/23%) # Last errno 0 # Users appuser01 (478323/87%), appuser02 (64465/11%), appuser03(5049/0%)
  • 63. pt-query-digest: Output per Query # Query_time distribution # 1us # 10us ## # 100us ################################################################ # 1ms #### # 10ms # # 100ms # # 1s # 10s+
  • 64. pt-query-digest: Output per Query # Tables # SHOW TABLE STATUS FROM `sphere` LIKE 'ApplicationUser'G # SHOW CREATE TABLE `sphere`.`ApplicationUser`G # SHOW TABLE STATUS FROM `sphere` LIKE 'Client'G # SHOW CREATE TABLE `sphere`.`Client`G # EXPLAIN /*!50100 PARTITIONS*/ SELECT au.*, c.active, c.clientEndDate FROM ApplicationUser au JOIN Client c ON au.clientId = c.clientId WHERE userId = 48954G
  • 65. pt-query-digest: Useful Switches !   --limit !   “Top-n” limit !   Percent and/or number of results !   --limit 95%:20 !   --limit 5 !   --limit 10%
  • 66. pt-query-digest: Useful Switches !   --show-all !   Show all values in lists, not just what fits on one line
  • 67. pt-query-digest: Useful Switches !   --order-by !   Specify how to sort the output !   Parameter is {metric}:{function} !   --order-by Query_time:sum (default) !   --order-by Bytes_sent:sum (interface saturation?) !   --order-by Rows_examined:sum (Find table scans) !   --order-by Query-time:cnt (find high QPS)
  • 68. pt-query-digest: Useful Switches !   --explain !   Explain each query !   Specify where to connect for the Explain Plan queries !   --explain h=myServer,P=3306,u=myUser,p=secret
  • 69. Generating Log Digests First: Get pt-query-digest wget percona.com/get/pt-query-digest chmod +x pt-query-digest
  • 70. Generating Log Digests Then: Enable the slow log for a limited time mysql –e'set global {all the settings from earlier}' mysql –e'set global slow_query_log=1' sleep 60 mysql –e'set global slow_query_log=0'
  • 71. Generating Log Digests Digest the resulting log… ./pt-query-digest /path/to/slow.log digest.txt
  • 72. Generating Log Digests (Periodic) For 10 minutes: •  Enable the slow log •  Wait 30 seconds •  Disable the slow log •  Wait 30 seconds Then… pt-query-digest --limit 5 --explain h=…,P=… /path/to/slow.log digest.txt
  • 73. Generating Log Digests (Emergency) •  Enable the slow log •  Wait 30 seconds •  Disable the slow log Then… pt-query-digest --show-all /path/to/slow.log digest.txt
  • 74. Interpreting Digested Logs !   Most important metric: total execution time 4 s 100 ms
  • 75. Interpreting Digested Logs !   Most important metric: total execution time 4 s 8 s
  • 76. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS
  • 77. pt-query-digest: Output # Profile # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== =============== ======= ====== ====== ==================================================== # 1 0x2AEA6C2B72904C1E 431.5703 13.4% 1578 0.2735 0.30 SELECT UNION Roles RoleGrants DefaultRolePermissions # 2 0x97C874BC88FDB2E3 226.4475 7.0% 48 4.7177 49.80 SELECT Event EventAttribute # 3 0x4A106EF2450AEAC1 119.0458 3.7% 547909 0.0002 0.03 SELECT ApplicationUser Client # 4 0x00694E9F0A0CD23D 113.0377 3.5% 313 0.3611 0.05 SELECT ExtendedMediaTypeAttribute TopicFilter # 5 0x813031B8BBC3B329 110.2512 3.4% 206088 0.0005 1.80 COMMIT # MISC 0xMISC 2218.8264 68.7% 5600850 0.0004 0.0 769 ITEMS Single Most Important Metric THEN look at each query, starting from the top
  • 78. Interpreting Digested Logs (Steps) !   Generate Digest, sorted by total execution time per query ! Start with Query #1; work your way down !   Don’t get distracted by other queries in the list, or not in the list ! Ignore the actual SQL until you start tuning
  • 79. Interpreting Digested Logs (Steps) Two main reasons for appearing on the list: !   High queries-per-second (high enough that fast queries are making the list) !   Expensive query (not running often, but when they do…) And also… !   “Sort of expensive” — fast enough, except when we run a lot of them
  • 80. Interpreting Digested Logs (examples) # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== ============== ======= ======= ====== ================================== # 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes # 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants # 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException # 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup FilterQuery
  • 81. Interpreting Digested Logs (example 1) Reality-based…
  • 82. Interpreting Digested Logs (example 1) # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== ============== ======= ======= ====== ================================== # 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes # 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants # 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException # 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup FilterQuery
  • 83. # Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036 # Scores: V/M = 2.40 # Time range: 2015-03-29 09:55:10 to 10:04:31 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 255 # Exec time 25 607s 8ms 6s 2s 5s 2s 2s # Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us # Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17 # Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k # Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34 Interpreting Digested Logs (example 1)
  • 84. # Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036 # Scores: V/M = 2.40 # Time range: 2015-03-29 09:55:10 to 10:04:31 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 255 # Exec time 25 607s 8ms 6s 2s 5s 2s 2s # Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us # Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17 # Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k # Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34 Interpreting Digested Logs (example 1)
  • 85. # Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036 # Scores: V/M = 2.40 # Time range: 2015-03-29 09:55:10 to 10:04:31 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 255 # Exec time 25 607s 8ms 6s 2s 5s 2s 2s # Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us # Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17 # Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k # Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34 Interpreting Digested Logs (example 1)
  • 86. # Query 1: 0.45 QPS, 1.08x concurrency, ID 0xA4129148F8ED32B2 at byte 1012395036 # Scores: V/M = 2.40 # Time range: 2015-03-29 09:55:10 to 10:04:31 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 255 # Exec time 25 607s 8ms 6s 2s 5s 2s 2s # Lock time 0 135ms 21us 4ms 529us 2ms 793us 64us # Rows sent 0 49.95k 0 372 200.58 346.17 160.67 346.17 # Rows examine 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 0 2.67M 10.73k 10.73k 10.73k 10.73k 0 10.73k # Bytes sent 0 1.11M 339 7.96k 4.44k 7.31k 3.24k 7.31k # Query size 0 30.37k 118 122 121.97 118.34 0.35 118.34 Interpreting Digested Logs (example 1)
  • 87. # Query_time distribution # 1us # 10us # 100us # 1ms # # 10ms ################################################## # 100ms ####### # 1s ################################################################ # 10s+ Interpreting Digested Logs (example 1)
  • 88. Interpreting Digested Logs (example 1) select userId, clientId, userAttributeTypeId, value from UserAttributes where clientId = 23495 and userAttributeTypeId = 1G # *************************** 1. row *************************** # id: 1 # select_type: SIMPLE # table: UserAttributes # partitions: NULL # type: ALL # possible_keys: NULL # key: NULL # key_len: NULL # ref: NULL # rows: 11270 # Extra: Using where
  • 89. Interpreting Digested Logs (example 1) select userId, clientId, userAttributeTypeId, value from UserAttributes where clientId = 23495 and userAttributeTypeId = 1G # *************************** 1. row *************************** # id: 1 # select_type: SIMPLE # table: UserAttributes # partitions: NULL # type: ALL # possible_keys: NULL # key: NULL # key_len: NULL # ref: NULL # rows: 11270 # Extra: Using where
  • 90. Interpreting Digested Logs (example 1) select userId, clientId, userAttributeTypeId, value from UserAttributes where clientId = 23495 and userAttributeTypeId = 1G # *************************** 1. row *************************** # id: 1 # select_type: SIMPLE # table: UserAttributes # partitions: NULL # type: ALL # possible_keys: NULL # key: NULL # key_len: NULL # ref: NULL # rows: 11270 # Extra: Using where New index required.
  • 91. Interpreting Digested Logs (example 2) Reality-based…
  • 92. # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== ============== ======= ======= ====== ================================== # 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes # 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants # 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException # 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup FilterQuery Interpreting Digested Logs (example 2)
  • 93. # Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570 # Scores: V/M = 0.24 # Time range: 2015-03-29 09:55:08 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 1346 # Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms # Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us # Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83 # Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84 # Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k Interpreting Digested Logs (example 2)
  • 94. # Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570 # Scores: V/M = 0.24 # Time range: 2015-03-29 09:55:08 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 1346 # Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms # Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us # Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83 # Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84 # Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k Interpreting Digested Logs (example 2)
  • 95. # Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570 # Scores: V/M = 0.24 # Time range: 2015-03-29 09:55:08 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 1346 # Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms # Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us # Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83 # Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84 # Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k Interpreting Digested Logs (example 2)
  • 96. # Query 2: 2.38 QPS, 0.69x concurrency, ID 0x2AEA6C2B72904C1E at byte 367386570 # Scores: V/M = 0.24 # Time range: 2015-03-29 09:55:08 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 1346 # Exec time 16 390s 60ms 2s 289ms 740ms 265ms 141ms # Lock time 0 762ms 228us 16ms 566us 1ms 1ms 348us # Rows sent 0 379.60k 0 14.55k 288.79 346.17 1.71k 9.83 # Rows examine 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 42 192.12M 508 3.65M 146.16k 174.27k 563.30k 9.33k # Bytes sent 0 4.17M 69 160.12k 3.17k 3.69k 18.78k 174.84 # Query size 0 3.45M 2.58k 2.63k 2.62k 2.62k 25 2.62k Interpreting Digested Logs (example 2)
  • 97. # Query_time distribution # 1us # 10us # 100us # 1ms # 10ms ############################# # 100ms ################################################################ # 1s # # 10s+ Interpreting Digested Logs (example 2)
  • 99. Interpreting Digested Logs (example 3) Reality-based…
  • 100. # Rank Query ID Response time Calls R/Call V/M Item # ==== ================== ============== ======= ======= ====== ================================== # 1 0xA4129148F8ED32B2 607.1264 25.3% 255 2.3809 2.40 SELECT UserAttributes # 2 0x2AEA6C2B72904C1E 389.5737 16.2% 1346 0.2894 0.24 SELECT UNION Roles RoleGrants # 3 0xFB33D80D68CDD066 146.5731 6.1% 15175 0.0097 9.27 SELECT PostStatusException # 4 0xC1EDA7581D372A3F 139.4136 5.8% 4 34.8534 1.35 SELECT TopicFilter FilterGroup FilterQuery Interpreting Digested Logs (example 3)
  • 101. # Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949 # Scores: V/M = 9.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 15175 # Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us # Lock time 0 704ms 19us 11ms 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0 # Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40 # Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58 Interpreting Digested Logs (example 3)
  • 102. # Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949 # Scores: V/M = 9.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 15175 # Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us # Lock time 0 704ms 19us 11ms 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0 # Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40 # Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58 Interpreting Digested Logs (example 3)
  • 103. # Query 3: 26.48 QPS, 0.26x concurrency, ID 0xFB33D80D68CDD066 at byte 1736951949 # Scores: V/M = 9.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 15175 # Exec time 6 147s 105us 18s 10ms 1ms 299ms 152us # Lock time 0 704ms 19us 11ms 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64M 3.11k 30.19 93.65k 0 # Rows examine 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55k 40.45 107.60k 0 # Bytes sent 12 879.86M 207 88.14M 59.37k 793.42 1.76M 202.40 # Query size 0 2.87M 185 530 198.43 212.52 49.09 183.58 Interpreting Digested Logs (example 3)
  • 104. # Query_time distribution # 1us # 10us # 100us ################################################################ # 1ms ### # 10ms # # 100ms # # 1s # # 10s+ # Interpreting Digested Logs (example 3)
  • 105. select blogPostId, postStatusId from PostStatusException where topicFilterId in (560938,549993) and publishedDate between '2014-05-02 22:34:22' and '2015-03-29 10:02:12’G # *************************** 1. row *************************** # id: 1 # select_type: SIMPLE # table: PostStatusException # partitions: NULL # type: range # possible_keys: PRIMARY,topicFilterPublishedDate # key: PRIMARY # key_len: 4 # ref: NULL # rows: 13285286 # Extra: Using where Interpreting Digested Logs (example 3)
  • 106. •  Acceptable index in this case.! •  For this query, some predicates naturally return large result sets.! Interpreting Digested Logs (example 3)
  • 107. Interpreting Digested Logs (example 4) Not reality-based… But sometimes happens!
  • 108. Interpreting Digested Logs (example 4) # Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949 # Scores: V/M = 1.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 915175 # Exec time 26 205s 105us 802us 224us 118us 99us 198us # Lock time 0 704ms 19us 91us 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0 # Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0 # Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40 # Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
  • 109. Interpreting Digested Logs (example 4) # Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949 # Scores: V/M = 1.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 915175 # Exec time 26 205s 105us 802us 224us 118us 99us 198us # Lock time 0 704ms 19us 91us 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0 # Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0 # Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40 # Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
  • 110. Interpreting Digested Logs (example 4) # Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949 # Scores: V/M = 0.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 915175 # Exec time 26 205s 105us 802us 224us 118us 99us 198us # Lock time 0 704ms 19us 91us 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0 # Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0 # Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40 # Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
  • 111. Interpreting Digested Logs (example 4) # Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949 # Scores: V/M = 0.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 915175 # Exec time 26 205s 105us 802us 224us 118us 99us 198us # Lock time 0 704ms 19us 91us 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0 # Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0 # Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40 # Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
  • 112. Interpreting Digested Logs (example 4) # Query 2: 826.48 QPS, 8.26x concurrency, ID 0x4B33D80D68CDD066 at byte 176951949 # Scores: V/M = 0.27 # Time range: 2015-03-29 09:55:01 to 10:04:34 # Attribute pct total min max avg 95% stddev median # ============ === ======= ======= ======= ======= ======= ======= ======= # Count 0 915175 # Exec time 26 205s 105us 802us 224us 118us 99us 198us # Lock time 0 704ms 19us 91us 46us 57us 232us 26us # Rows sent 29 46.15M 0 4.64 3.11 3.19 2.05 0 # Rows examine 11 52.57M 0 5.21 3.55 4.45 2.60 0 # Rows affecte 0 0 0 0 0 0 0 0 # Rows read 11 52.57M 0 5.21M 3.55 40.45 107.60 0 # Bytes sent 12 979.86M 207 88.14k 59.37 793.42 1.76k 202.40 # Query size 0 22.87M 185 530 198.43 212.52 49.09 183.58
  • 113. Interpreting Digested Logs (other cases) # Databases schema1 (813422/89%), schema2 (101753/11%) # Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%) # Last errno 0 # Users user1 (813422/89%), user2 (101753/11%)
  • 114. Interpreting Digested Logs (other cases) # Databases schema1 (813422/89%), schema2 (101753/11%) # Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%) # Last errno 0 # Users user1 (813422/89%), user2 (101753/11%)
  • 115. Interpreting Digested Logs (other cases) # Databases schema1 (813422/89%), schema2 (101753/11%) # Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%) # Last errno 0 # Users user1 (813422/89%), user2 (101753/11%)
  • 116. Interpreting Digested Logs (other cases) # Databases schema1 (813422/89%), schema2 (101753/11%) # Hosts ap1234 (813323/89%), ap2345 (89429/10%), ap3456 (12324/1%) # Last errno 0 # Users user1 (813422/89%), user2 (101753/11%) Talk to developers, verify logic Talk to Operations, verify traffic pattern
  • 117. Trending !   Spreadsheet !   Set up database to accept pt-query-digest output (see --review and --history switches)
  • 118. Other Slow Log Analyses Finding Outliers! !   Reports of a slow query that doesn’t make it in the log digest # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN'; !   Dump out all access times from the slow log for this query: grep -B 3 'select * from actor where first_name' slow.log | grep Query | cut -f3 -d' ' | tr -d . file
  • 119. Other Slow Log Analyses Finding Outliers! !   Reports of a slow query that doesn’t make it in the log digest # Query_time: 0.019128 Lock_time: 0.009394 Rows_sent: 1 Rows_examined: 200 Rows_affected: 0 # Bytes_sent: 267 SET timestamp=1427633533; select * from actor where first_name='JOHN'; !   Go right nuts: Dump out all access times from the slow log for this query, including timestamps: grep -B 3 'select * from actor where first_name' slow.log | grep -E 'Query|timestamp' | cut -f2,3 -d' ' | tr '=' ' ' | (while read Q T; do read TS; echo $TS $T; done) | cut -f2,3 -d' ' | tr -d ';' file
  • 120. Extra Reading / Resources !   Percona Docs ! http://www.percona.com/doc/percona-server/5.5/diagnostics/ slow_extended_55.html ! http://www.percona.com/doc/percona-server/5.1/diagnostics/slow_extended.html? id=percona-server:features:slow_extended_51 ! http://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html !   MySQL Docs ! http://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html !   Slides, and script to safely do periodic slow log digests ! bit.ly/BobBurgessPercona2015