MySQL Meetup 
September 8th, 2014
Text 
Welcome! 
To the 1st of many MySQL Meetups!
Agenda: 
• Food and registration 5:30 - 6:30 
• Speaker 6:30 - 7:00 
• Questions 7:00 - 7:30 
• Networking 7:30 - 8:00
Quick Performance Check 
Presented by: Wayne Leutwyler
When a quick look is 
needed. 
Weekday management fire drill. 
2am OnCall page. 
Unhappy customer calls you to complain about 
response time. 
Or anytime you just want to see how a certain database 
server is performing.
The Views. 
Below are 6 views that I find very useful for day today 
performance check, or the 2am issue. 
v_InnoBPHitRate 
v_table_cache_used 
v_table_definition_cache_use 
v_thread_cache_hit 
v_thread_cache_used 
v_tmp_to_disk
v_InnoBPHitRate 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_InnoBPHitRate` AS 
select 
round((100 - ((100 * `P2`.`VARIABLE_VALUE`) / 
`P1`.`VARIABLE_VALUE`)), 
2) AS `InnoBP Hit Rate`, 
`P2`.`VARIABLE_VALUE` AS `InnoBP Read Requests (from disk)`, 
`P1`.`VARIABLE_VALUE` AS `InnoBP Reads (from BP)` 
from 
(`information_schema`.`GLOBAL_STATUS` `P1` 
join `information_schema`.`GLOBAL_STATUS` `P2`) 
where 
((`P1`.`VARIABLE_NAME` = 'innodb_buffer_pool_read_requests') 
and (`P2`.`VARIABLE_NAME` = 'innodb_buffer_pool_reads')) 
I have always gone with 50% 
of total server ram for my InnoDB 
buffer pool. Recommendations 
range from 50% to 80%.
v_table_cache_used 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_table_cache_used` AS 
select 
round(((`information_schema`.`global_status`.`VARIABLE_VALUE` / 
`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 
100), 
2) AS `Table Cache % Used` 
from 
(`information_schema`.`global_status` 
join `information_schema`.`GLOBAL_VARIABLES`) 
where 
((`information_schema`.`global_status`.`VARIABLE_NAME` = 
'opened_tables') 
and 
(`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 
'table_open_cache')) 
Below 90% Adjust: 
table_open_cache
v_table_definition_cache_use 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_table_definition_cache_used` AS 
select 
round(((`information_schema`.`global_status`.`VARIABLE_VALUE` 
/ `information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 
100), 
2) AS `Table Definition Cache % Used` 
from 
(`information_schema`.`global_status` 
join `information_schema`.`GLOBAL_VARIABLES`) 
where 
((`information_schema`.`global_status`.`VARIABLE_NAME` = 
'open_table_definitions') 
and 
(`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 
'table_definition_cache')) 
Above 100% adjust: 
table_definition_cache
v_thread_cache_hit 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_thread_cache_hit` AS 
select 
round((100 - ((`p1`.`VARIABLE_VALUE` / `p2`.`VARIABLE_VALUE`) * 
100)), 
2) AS `Thread Cache Hit Rate`, 
`p1`.`VARIABLE_VALUE` AS `Threads Created`, 
`p2`.`VARIABLE_VALUE` AS `Connections` 
from 
(`information_schema`.`global_status` `p1` 
join `information_schema`.`global_status` `p2`) 
where 
((`p1`.`VARIABLE_NAME` = 'threads_created') 
and (`p2`.`VARIABLE_NAME` = 'connections')) 
Below 90% adjust: 
thread_cache_size
v_thread_cache_used 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_thread_cache_used` AS 
select 
round(((`information_schema`.`global_status`.`VARIABLE_VALUE` 
/ `information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 
100), 
2) AS `Thread Cache % Used` 
from 
(`information_schema`.`global_status` 
join `information_schema`.`GLOBAL_VARIABLES`) 
where 
((`information_schema`.`global_status`.`VARIABLE_NAME` = 
'threads_cached') 
and 
(`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 
'thread_cache_size')) 
Above 100% adjust: 
thread_cache_size
v_tmp_to_disk 
CREATE 
ALGORITHM = UNDEFINED 
DEFINER = `wayne`@`localhost` 
SQL SECURITY DEFINER 
VIEW `v_tmp_to_disk` AS 
select 
round(((`p1`.`VARIABLE_VALUE` / `p2`.`VARIABLE_VALUE`) 
* 100), 
2) AS `Percent TMP to Disk` 
from 
(`information_schema`.`global_status` `p1` 
join `information_schema`.`global_status` `p2`) 
where 
((`p1`.`VARIABLE_NAME` = 
'CREATED_TMP_DISK_TABLES') 
and (`p2`.`VARIABLE_NAME` = 
'CREATED_TMP_TABLES')) 
If percent is 25% or higher 
adjust: 
tmp_table_size 
max_heap_table_size
Command Line Tools 
When you cant find an issue with the DB, time 
to check the system. 
top 
iostat 
vmstat 
free
House Keeping 
Put your trash in the proper place. 
Don’t wonder around the building. 
Please put the chairs back the way they were. 
Please keep the noise down. We don’t want to 
disturb people still working.
Thank you! 
Percona for the food and drinks. 
CareWorks Tech for hosting our meeting.
Thank You 
questions? 
The views expressed in this presentation are mine alone.

Quick MySQL performance check

  • 1.
  • 2.
    Text Welcome! Tothe 1st of many MySQL Meetups!
  • 3.
    Agenda: • Foodand registration 5:30 - 6:30 • Speaker 6:30 - 7:00 • Questions 7:00 - 7:30 • Networking 7:30 - 8:00
  • 4.
    Quick Performance Check Presented by: Wayne Leutwyler
  • 5.
    When a quicklook is needed. Weekday management fire drill. 2am OnCall page. Unhappy customer calls you to complain about response time. Or anytime you just want to see how a certain database server is performing.
  • 6.
    The Views. Beloware 6 views that I find very useful for day today performance check, or the 2am issue. v_InnoBPHitRate v_table_cache_used v_table_definition_cache_use v_thread_cache_hit v_thread_cache_used v_tmp_to_disk
  • 7.
    v_InnoBPHitRate CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_InnoBPHitRate` AS select round((100 - ((100 * `P2`.`VARIABLE_VALUE`) / `P1`.`VARIABLE_VALUE`)), 2) AS `InnoBP Hit Rate`, `P2`.`VARIABLE_VALUE` AS `InnoBP Read Requests (from disk)`, `P1`.`VARIABLE_VALUE` AS `InnoBP Reads (from BP)` from (`information_schema`.`GLOBAL_STATUS` `P1` join `information_schema`.`GLOBAL_STATUS` `P2`) where ((`P1`.`VARIABLE_NAME` = 'innodb_buffer_pool_read_requests') and (`P2`.`VARIABLE_NAME` = 'innodb_buffer_pool_reads')) I have always gone with 50% of total server ram for my InnoDB buffer pool. Recommendations range from 50% to 80%.
  • 8.
    v_table_cache_used CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_table_cache_used` AS select round(((`information_schema`.`global_status`.`VARIABLE_VALUE` / `information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 100), 2) AS `Table Cache % Used` from (`information_schema`.`global_status` join `information_schema`.`GLOBAL_VARIABLES`) where ((`information_schema`.`global_status`.`VARIABLE_NAME` = 'opened_tables') and (`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 'table_open_cache')) Below 90% Adjust: table_open_cache
  • 9.
    v_table_definition_cache_use CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_table_definition_cache_used` AS select round(((`information_schema`.`global_status`.`VARIABLE_VALUE` / `information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 100), 2) AS `Table Definition Cache % Used` from (`information_schema`.`global_status` join `information_schema`.`GLOBAL_VARIABLES`) where ((`information_schema`.`global_status`.`VARIABLE_NAME` = 'open_table_definitions') and (`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 'table_definition_cache')) Above 100% adjust: table_definition_cache
  • 10.
    v_thread_cache_hit CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_thread_cache_hit` AS select round((100 - ((`p1`.`VARIABLE_VALUE` / `p2`.`VARIABLE_VALUE`) * 100)), 2) AS `Thread Cache Hit Rate`, `p1`.`VARIABLE_VALUE` AS `Threads Created`, `p2`.`VARIABLE_VALUE` AS `Connections` from (`information_schema`.`global_status` `p1` join `information_schema`.`global_status` `p2`) where ((`p1`.`VARIABLE_NAME` = 'threads_created') and (`p2`.`VARIABLE_NAME` = 'connections')) Below 90% adjust: thread_cache_size
  • 11.
    v_thread_cache_used CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_thread_cache_used` AS select round(((`information_schema`.`global_status`.`VARIABLE_VALUE` / `information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_VALUE`) * 100), 2) AS `Thread Cache % Used` from (`information_schema`.`global_status` join `information_schema`.`GLOBAL_VARIABLES`) where ((`information_schema`.`global_status`.`VARIABLE_NAME` = 'threads_cached') and (`information_schema`.`GLOBAL_VARIABLES`.`VARIABLE_NAME` = 'thread_cache_size')) Above 100% adjust: thread_cache_size
  • 12.
    v_tmp_to_disk CREATE ALGORITHM= UNDEFINED DEFINER = `wayne`@`localhost` SQL SECURITY DEFINER VIEW `v_tmp_to_disk` AS select round(((`p1`.`VARIABLE_VALUE` / `p2`.`VARIABLE_VALUE`) * 100), 2) AS `Percent TMP to Disk` from (`information_schema`.`global_status` `p1` join `information_schema`.`global_status` `p2`) where ((`p1`.`VARIABLE_NAME` = 'CREATED_TMP_DISK_TABLES') and (`p2`.`VARIABLE_NAME` = 'CREATED_TMP_TABLES')) If percent is 25% or higher adjust: tmp_table_size max_heap_table_size
  • 13.
    Command Line Tools When you cant find an issue with the DB, time to check the system. top iostat vmstat free
  • 14.
    House Keeping Putyour trash in the proper place. Don’t wonder around the building. Please put the chairs back the way they were. Please keep the noise down. We don’t want to disturb people still working.
  • 15.
    Thank you! Perconafor the food and drinks. CareWorks Tech for hosting our meeting.
  • 16.
    Thank You questions? The views expressed in this presentation are mine alone.