Quick MySQL performance check

Preview:

DESCRIPTION

This was the presentation by Wayne Leutwyler at the inaugural Central Ohio MySQL Meetup Group.

Citation preview

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 CheckPresented 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.

v_InnoBPHitRate

v_table_cache_used

v_table_definition_cache_use

v_thread_cache_hit

v_thread_cache_used

v_tmp_to_disk

Below are 6 views that I find very useful for day today performance check, or the 2am issue.

v_InnoBPHitRateCREATE

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 InnoDBbuffer pool. Recommendations range from 50% to 80%.

v_table_cache_usedCREATE

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_useCREATE

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_usedCREATE

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_diskCREATE

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_sizemax_heap_table_size

Command Line Tools

top

iostat

vmstat

free

When you cant find an issue with the DB, time to check the system.

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.

The views expressed in this presentation are mine alone.

Thank You

questions?

Recommended