SlideShare a Scribd company logo
1 of 23
Download to read offline
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
Senior Principal Technical Support Engineer
Overview
What is inside?
• MySQL 5.6
52 tables
554 instruments
31 variables
• MySQL 5.7
76 tables
893 instruments
40 variables
Overview
What can you troubleshoot?
• Internal server’s bottlenecks, caused by locks,
mutexes, IO
• Less optimal statements
• Most expensive operations
• Connection issues
• Memory usage
• Replication failures
• More
Basic setup
• Setup tables
UPDATE performance_schema.setup_instruments
SET enabled=’yes’, timed=’yes’
WHERE name LIKE ’stage/%’;
UPDATE performance_schema.setup_consumers
SET enabled=’yes’ WHERE name LIKE ...;
...
• Install sys schema
https://github.com/MarkLeith/mysql-sys
Install functions and run stored routine
$mysql < sys_57.sql
CALL sys.ps_setup_enable_consumers(’waits’);
CALL sys.ps_setup_enable_instrument(’’);
What happens inside MySQL server?
Available since version 5.5
• setup instruments.NAME
wait/io/file
• Operations with files
wait/io/socket
wait/io/table/sql/handler
wait/lock/table/sql/handler
wait/synch/cond
• InnoDB, MyISAM, sql
wait/synch/mutex
• sql, mysys, storage engines
wait/synch/rwlock/
• InnoDB, MyISAM, sql
What happens inside MySQL server?
Usage example
mysql> ALTER TABLE sbtest ADD KEY(c,pad);
...
• Run some load in parallel client
• Check Performance Schema using third connection
mysql> SELECT EVENT_NAME, COUNT_STAR,
-> AVG_TIMER_WAIT FROM performance_schema.
-> events_waits_summary_global_by_event_name
-> WHERE count_star>0
-> ORDER BY avg_timer_wait DESC, count_star DESCG
<See next slide>
What happens inside MySQL server?
Usage example, page 2
********************** 4. row **********************
EVENT_NAME: wait/io/file/innodb/innodb_temp_file
COUNT_STAR: 3196
AVG_TIMER_WAIT: 13644966830
********************** 5. row **********************
EVENT_NAME: wait/io/file/innodb/innodb_data_file
COUNT_STAR: 32694
AVG_TIMER_WAIT: 2927208612
********************** 6. row **********************
EVENT_NAME: wait/io/file/sql/FRM
COUNT_STAR: 153
AVG_TIMER_WAIT: 751453606
********************** 7. row **********************
EVENT_NAME: wait/synch/rwlock/innodb/index_tree_rw_lock
COUNT_STAR: 1369436
AVG_TIMER_WAIT: 83586370
What happens inside MySQL server?
Usage example, page 3
mysql> SELECT file, count_write cw,
-> total_written tw
-> FROM sys.io_global_by_file_by_bytes
-> WHERE count_write>0 ORDER BY count_write DESC;
+---------------------------------+-----+---------+
| file | cw | tw |
+---------------------------------+-----+---------+
| @@datadir/sbtest/sbtest.ibd |16830|479.53MiB|
| @@datadir/ibdata1 |4072 |372.44MiB|
| @@datadir/Innodb Merge Temp File| 1595| 1.56GiB |
...
Why your statements are slow?
Available since version 5.6
• events statements * tables
Statements
• statement/sql/delete
• statement/sql/select
• ...
Commands
• COM PING, COM QUIT, ...
• statement/com/Ping
• statement/com/Quit
Errors
• statement/sql/error
• statement/com/Error
• statement/sp/error
Stored Routines
• statement/sp
Statements tables: usage example
Which queries do not use indexes?
mysql> SELECT THREAD_ID AS TID, SUBSTR(SQL_TEXT, 1, 50)
-> AS SQL_TEXT, ROWS_SENT AS RS, ROWS_EXAMINED AS RE,
-> CREATED_TMP_TABLES, NO_INDEX_USED,
-> NO_GOOD_INDEX_USED FROM performance_schema.
-> events_statements_history WHERE NO_INDEX_USED=1
-> OR NO_GOOD_INDEX_USED=1G
********************** 1. row **********************
TID: 10124
SQL_TEXT: select emp_no, first_name,
last_name from employee
RS: 97750
RE: 397774
CREATED_TMP_TABLES: 0
NO_INDEX_USED: 1
NO_GOOD_INDEX_USED: 0
...
Statement tables: take it easy
Indes usage with sys schema
mysql> SELECT query, total_latency,
-> no_index_used_count, rows_sent,
-> rows_examined FROM
-> sys.statements_with_full_table_scans
-> WHERE db=’employees’ AND
-> query NOT LIKE ’%performance_schema%’G
********************** 1. row **********************
query: SELECT COUNT ( ‘emp_no‘ ) FROM ...
WHERE ‘title‘ = ?
total_latency: 805.37 ms
no_index_used_count: 1
rows_sent: 1
rows_examined: 397774
...
Statement tables
What else is worth attention?
• Field names
CREATED TMP DISK TABLES
CREATED TMP TABLES
SELECT FULL JOIN
SELECT RANGE CHECK
SELECT SCAN
SORT MERGE PASSES
SORT SCAN
• Views in sys schema
statement analysis
statements with runtimes in 95th percentile
statements with temp tables
statements with sorting
statements with full table scans
statements with errors or warnings
Which operations are most expensive?
Available since version 5.6
• events stages * tables
• Same information which you see in table
INFORMATION SCHEMA.PROCESSLIST or SHOW
PROCESSLIST output
init
executing
Opening tables
...
• Replacement for SHOW PROFILE
• Only server-level
• No information from storage engine in this table!
events stages * tables: usage example
Which states took critically long time?
mysql> SELECT eshl.event_name, sql_text,
-> eshl.timer_wait/1000000000000 wait_s
-> FROM performance_schema.events_stages_history_long
-> eshl JOIN performance_schema.
-> events_statements_history_long esthl ON
-> (eshl.nesting_event_id = esthl.event_id)
-> WHERE eshl.timer_wait > 1*10000000000G
********************** 1. row **********************
event_name: stage/sql/Sending data
sql_text: select count(emp_no) from employees
join salaries
using(emp_no) where hire_date = from_date
wait_s: 0.8170
1 row in set (0.00 sec)
events stages * tables
What else is worth attention?
• Everything, related to temporary tables
EVENT NAME LIKE ’stage/sql/%tmp%’
• Everything, related to locks
EVENT NAME LIKE ’stage/sql/%lock%’
• Everything in state ”Waiting for”
EVENT NAME LIKE ’stage/%/Waiting for%’
• Frequently met issues (based on MySQL Support
Team experience)
EVENT NAME=’stage/sql/end’
EVENT NAME=’stage/sql/freeing items’
EVENT NAME=’stage/sql/Sending data’
EVENT NAME=’stage/sql/cleaning up’
EVENT NAME=’stage/sql/closing tables’
Where is all your RAM?
Available since version 5.7
• Memory summary tables
• sys.memory * views
• Detailed information about memory usage of each
server’s internal
• Total amount of memory, allocated by the server
mysql> SELECT * FROM sys.memory_global_total;
+-----------------+
| total_allocated |
+-----------------+
| 458.44 MiB |
+-----------------+
Memory summary tables
Usage example
mysql> SELECT thread_id, user, current_avg_alloc, curre
-> FROM sys.memory_by_thread_by_current_bytes
-> WHERE thread_id IN 145, 146)G
********************** 1. row **********************
thread_id: 145
user: sql/slave_io
current_allocated: 1.04 GiB
current_avg_alloc: 2.64 KiB
********************** 2. row **********************
thread_id: 146
user: sql/slave_sql
current_allocated: 1.79 MiB
current_avg_alloc: 72 bytes
2 rows in set (0.11 sec)
Memory summary tables
What else is worth attention?
• Tables in Performance Schema
memory summary global by event name
memory summary by account by event name
memory summary by host by event name
memory summary by thread by event name
memory summary by user by event name
• Views in sys schema
memory global total
memory by thread by current bytes
memory by host by current bytes
memory by user by current bytes
memory global by current allocated
What did I miss?
You can do even more!
• MDL locks instrumentation
• host cache table and all information you need to
troubleshoot connection issues
• Replication tables: you don’t need to parse SHOW
TABLE STATUS output in your scripts anymore
• Hundreds of instruments
• How to tune Performance schema
References
• http://marcalff.blogspot.ru
• https://github.com/MarkLeith/mysql-sys
• http://dimitrik.free.fr/blog/
• http://dev.mysql.com/doc/refman/5.7/en/
performance-schema.html
• https://blogs.oracle.com/svetasmirnova/tags/
performance_schema
• http://www.slideshare.net/SvetaSmirnova/
performance-schema-for-mysql-troubleshooting
Thank you
?
The preceding is intended to outline our general product
direction. It is intended for information purposes only, and
may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality,
and should not be relied upon in making purchasing
decisions. The development, release, and timing of any
features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.

More Related Content

What's hot

MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossuk
Valeriy Kravchuk
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQL
Padraig O'Sullivan
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
HighLoad2009
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
Valeriy Kravchuk
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
Ronald Bradford
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
Roland Bouman
 

What's hot (20)

Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101
 
MySQL Troubleshooting with the Performance Schema
MySQL Troubleshooting with the Performance SchemaMySQL Troubleshooting with the Performance Schema
MySQL Troubleshooting with the Performance Schema
 
Moving to the NoSQL side: MySQL JSON functions
 Moving to the NoSQL side: MySQL JSON functions Moving to the NoSQL side: MySQL JSON functions
Moving to the NoSQL side: MySQL JSON functions
 
Performance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshootingPerformance Schema for MySQL troubleshooting
Performance Schema for MySQL troubleshooting
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015Character Encoding - MySQL DevRoom - FOSDEM 2015
Character Encoding - MySQL DevRoom - FOSDEM 2015
 
Preparse Query Rewrite Plugins
Preparse Query Rewrite PluginsPreparse Query Rewrite Plugins
Preparse Query Rewrite Plugins
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
Troubleshooting MySQL Performance add-ons
Troubleshooting MySQL Performance add-onsTroubleshooting MySQL Performance add-ons
Troubleshooting MySQL Performance add-ons
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossuk
 
Capturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQLCapturing, Analyzing, and Optimizing your SQL
Capturing, Analyzing, and Optimizing your SQL
 
Highload Perf Tuning
Highload Perf TuningHighload Perf Tuning
Highload Perf Tuning
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
 
Summary tables with flexviews
Summary tables with flexviewsSummary tables with flexviews
Summary tables with flexviews
 
Mini Session - Using GDB for Profiling
Mini Session - Using GDB for ProfilingMini Session - Using GDB for Profiling
Mini Session - Using GDB for Profiling
 
Mysql 56-experiences-bugs-solutions-50mins
Mysql 56-experiences-bugs-solutions-50minsMysql 56-experiences-bugs-solutions-50mins
Mysql 56-experiences-bugs-solutions-50mins
 
10x Performance Improvements
10x Performance Improvements10x Performance Improvements
10x Performance Improvements
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 

Viewers also liked

Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)
Ontico
 
Introduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise MonitorIntroduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise Monitor
Mark Leith
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helper
Mark Leith
 
MySQL 5.6 Performance
MySQL 5.6 PerformanceMySQL 5.6 Performance
MySQL 5.6 Performance
MYXPLAIN
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server Changes
Morgan Tocker
 
Mysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sysMysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sys
Mark Leith
 

Viewers also liked (20)

MySQL Performance - SydPHP October 2011
MySQL Performance - SydPHP October 2011MySQL Performance - SydPHP October 2011
MySQL Performance - SydPHP October 2011
 
Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)Performance Schema in MySQL (Danil Zburivsky)
Performance Schema in MySQL (Danil Zburivsky)
 
The MySQL Performance Schema & New SYS Schema
The MySQL Performance Schema & New SYS SchemaThe MySQL Performance Schema & New SYS Schema
The MySQL Performance Schema & New SYS Schema
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
Introduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise MonitorIntroduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise Monitor
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema Plugins
 
Getting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise MonitorGetting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise Monitor
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helper
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
 
MySQL User Camp: GTIDs
MySQL User Camp: GTIDsMySQL User Camp: GTIDs
MySQL User Camp: GTIDs
 
MySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL ClusterMySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL Cluster
 
MySQL 5.6 Performance
MySQL 5.6 PerformanceMySQL 5.6 Performance
MySQL 5.6 Performance
 
MySQL 5.7: Core Server Changes
MySQL 5.7: Core Server ChangesMySQL 5.7: Core Server Changes
MySQL 5.7: Core Server Changes
 
MySQL NoSQL APIs
MySQL NoSQL APIsMySQL NoSQL APIs
MySQL NoSQL APIs
 
Open source India - MySQL Labs: Multi-Source Replication
Open source India - MySQL Labs: Multi-Source ReplicationOpen source India - MySQL Labs: Multi-Source Replication
Open source India - MySQL Labs: Multi-Source Replication
 
Mysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sysMysql tech day_paris_ps_and_sys
Mysql tech day_paris_ps_and_sys
 
MySQL 5.7 New Features for Developers
MySQL 5.7 New Features for DevelopersMySQL 5.7 New Features for Developers
MySQL 5.7 New Features for Developers
 

Similar to Performance Schema for MySQL Troubleshooting

MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
What's New In MySQL 5.6
What's New In MySQL 5.6What's New In MySQL 5.6
What's New In MySQL 5.6
Abdul Manaf
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling Presentation
Tommy Falgout
 
Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
MySQLConference
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instruments
Marco Tusa
 

Similar to Performance Schema for MySQL Troubleshooting (20)

MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
MySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete TutorialMySQL Performance Schema in Action: the Complete Tutorial
MySQL Performance Schema in Action: the Complete Tutorial
 
MySQL sys schema deep dive
MySQL sys schema deep diveMySQL sys schema deep dive
MySQL sys schema deep dive
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
sveta smirnova - my sql performance schema in action
sveta smirnova - my sql performance schema in actionsveta smirnova - my sql performance schema in action
sveta smirnova - my sql performance schema in action
 
Performance Schema in Action: demo
Performance Schema in Action: demoPerformance Schema in Action: demo
Performance Schema in Action: demo
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
DPC Tutorial
DPC TutorialDPC Tutorial
DPC Tutorial
 
Tek tutorial
Tek tutorialTek tutorial
Tek tutorial
 
What's New In MySQL 5.6
What's New In MySQL 5.6What's New In MySQL 5.6
What's New In MySQL 5.6
 
MySQL Scaling Presentation
MySQL Scaling PresentationMySQL Scaling Presentation
MySQL Scaling Presentation
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a Nutshell
 
Memcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My SqlMemcached Functions For My Sql Seemless Caching In My Sql
Memcached Functions For My Sql Seemless Caching In My Sql
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
Empower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instrumentsEmpower my sql server administration with 5.7 instruments
Empower my sql server administration with 5.7 instruments
 

More from Sveta Smirnova

MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB ClusterHow to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 

More from Sveta Smirnova (20)

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
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
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOps
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB ClusterHow to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsHow to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tears
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Recently uploaded (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 

Performance Schema for MySQL Troubleshooting

  • 1. Performance Schema for MySQL Troubleshooting Sveta Smirnova Senior Principal Technical Support Engineer
  • 2. Overview What is inside? • MySQL 5.6 52 tables 554 instruments 31 variables • MySQL 5.7 76 tables 893 instruments 40 variables
  • 3. Overview What can you troubleshoot? • Internal server’s bottlenecks, caused by locks, mutexes, IO • Less optimal statements • Most expensive operations • Connection issues • Memory usage • Replication failures • More
  • 4. Basic setup • Setup tables UPDATE performance_schema.setup_instruments SET enabled=’yes’, timed=’yes’ WHERE name LIKE ’stage/%’; UPDATE performance_schema.setup_consumers SET enabled=’yes’ WHERE name LIKE ...; ... • Install sys schema https://github.com/MarkLeith/mysql-sys Install functions and run stored routine $mysql < sys_57.sql CALL sys.ps_setup_enable_consumers(’waits’); CALL sys.ps_setup_enable_instrument(’’);
  • 5. What happens inside MySQL server? Available since version 5.5 • setup instruments.NAME wait/io/file • Operations with files wait/io/socket wait/io/table/sql/handler wait/lock/table/sql/handler wait/synch/cond • InnoDB, MyISAM, sql wait/synch/mutex • sql, mysys, storage engines wait/synch/rwlock/ • InnoDB, MyISAM, sql
  • 6. What happens inside MySQL server? Usage example mysql> ALTER TABLE sbtest ADD KEY(c,pad); ... • Run some load in parallel client • Check Performance Schema using third connection mysql> SELECT EVENT_NAME, COUNT_STAR, -> AVG_TIMER_WAIT FROM performance_schema. -> events_waits_summary_global_by_event_name -> WHERE count_star>0 -> ORDER BY avg_timer_wait DESC, count_star DESCG <See next slide>
  • 7. What happens inside MySQL server? Usage example, page 2 ********************** 4. row ********************** EVENT_NAME: wait/io/file/innodb/innodb_temp_file COUNT_STAR: 3196 AVG_TIMER_WAIT: 13644966830 ********************** 5. row ********************** EVENT_NAME: wait/io/file/innodb/innodb_data_file COUNT_STAR: 32694 AVG_TIMER_WAIT: 2927208612 ********************** 6. row ********************** EVENT_NAME: wait/io/file/sql/FRM COUNT_STAR: 153 AVG_TIMER_WAIT: 751453606 ********************** 7. row ********************** EVENT_NAME: wait/synch/rwlock/innodb/index_tree_rw_lock COUNT_STAR: 1369436 AVG_TIMER_WAIT: 83586370
  • 8. What happens inside MySQL server? Usage example, page 3 mysql> SELECT file, count_write cw, -> total_written tw -> FROM sys.io_global_by_file_by_bytes -> WHERE count_write>0 ORDER BY count_write DESC; +---------------------------------+-----+---------+ | file | cw | tw | +---------------------------------+-----+---------+ | @@datadir/sbtest/sbtest.ibd |16830|479.53MiB| | @@datadir/ibdata1 |4072 |372.44MiB| | @@datadir/Innodb Merge Temp File| 1595| 1.56GiB | ...
  • 9. Why your statements are slow? Available since version 5.6 • events statements * tables Statements • statement/sql/delete • statement/sql/select • ... Commands • COM PING, COM QUIT, ... • statement/com/Ping • statement/com/Quit Errors • statement/sql/error • statement/com/Error • statement/sp/error Stored Routines • statement/sp
  • 10. Statements tables: usage example Which queries do not use indexes? mysql> SELECT THREAD_ID AS TID, SUBSTR(SQL_TEXT, 1, 50) -> AS SQL_TEXT, ROWS_SENT AS RS, ROWS_EXAMINED AS RE, -> CREATED_TMP_TABLES, NO_INDEX_USED, -> NO_GOOD_INDEX_USED FROM performance_schema. -> events_statements_history WHERE NO_INDEX_USED=1 -> OR NO_GOOD_INDEX_USED=1G ********************** 1. row ********************** TID: 10124 SQL_TEXT: select emp_no, first_name, last_name from employee RS: 97750 RE: 397774 CREATED_TMP_TABLES: 0 NO_INDEX_USED: 1 NO_GOOD_INDEX_USED: 0 ...
  • 11. Statement tables: take it easy Indes usage with sys schema mysql> SELECT query, total_latency, -> no_index_used_count, rows_sent, -> rows_examined FROM -> sys.statements_with_full_table_scans -> WHERE db=’employees’ AND -> query NOT LIKE ’%performance_schema%’G ********************** 1. row ********************** query: SELECT COUNT ( ‘emp_no‘ ) FROM ... WHERE ‘title‘ = ? total_latency: 805.37 ms no_index_used_count: 1 rows_sent: 1 rows_examined: 397774 ...
  • 12. Statement tables What else is worth attention? • Field names CREATED TMP DISK TABLES CREATED TMP TABLES SELECT FULL JOIN SELECT RANGE CHECK SELECT SCAN SORT MERGE PASSES SORT SCAN • Views in sys schema statement analysis statements with runtimes in 95th percentile statements with temp tables statements with sorting statements with full table scans statements with errors or warnings
  • 13. Which operations are most expensive? Available since version 5.6 • events stages * tables • Same information which you see in table INFORMATION SCHEMA.PROCESSLIST or SHOW PROCESSLIST output init executing Opening tables ... • Replacement for SHOW PROFILE • Only server-level • No information from storage engine in this table!
  • 14. events stages * tables: usage example Which states took critically long time? mysql> SELECT eshl.event_name, sql_text, -> eshl.timer_wait/1000000000000 wait_s -> FROM performance_schema.events_stages_history_long -> eshl JOIN performance_schema. -> events_statements_history_long esthl ON -> (eshl.nesting_event_id = esthl.event_id) -> WHERE eshl.timer_wait > 1*10000000000G ********************** 1. row ********************** event_name: stage/sql/Sending data sql_text: select count(emp_no) from employees join salaries using(emp_no) where hire_date = from_date wait_s: 0.8170 1 row in set (0.00 sec)
  • 15. events stages * tables What else is worth attention? • Everything, related to temporary tables EVENT NAME LIKE ’stage/sql/%tmp%’ • Everything, related to locks EVENT NAME LIKE ’stage/sql/%lock%’ • Everything in state ”Waiting for” EVENT NAME LIKE ’stage/%/Waiting for%’ • Frequently met issues (based on MySQL Support Team experience) EVENT NAME=’stage/sql/end’ EVENT NAME=’stage/sql/freeing items’ EVENT NAME=’stage/sql/Sending data’ EVENT NAME=’stage/sql/cleaning up’ EVENT NAME=’stage/sql/closing tables’
  • 16. Where is all your RAM? Available since version 5.7 • Memory summary tables • sys.memory * views • Detailed information about memory usage of each server’s internal • Total amount of memory, allocated by the server mysql> SELECT * FROM sys.memory_global_total; +-----------------+ | total_allocated | +-----------------+ | 458.44 MiB | +-----------------+
  • 17. Memory summary tables Usage example mysql> SELECT thread_id, user, current_avg_alloc, curre -> FROM sys.memory_by_thread_by_current_bytes -> WHERE thread_id IN 145, 146)G ********************** 1. row ********************** thread_id: 145 user: sql/slave_io current_allocated: 1.04 GiB current_avg_alloc: 2.64 KiB ********************** 2. row ********************** thread_id: 146 user: sql/slave_sql current_allocated: 1.79 MiB current_avg_alloc: 72 bytes 2 rows in set (0.11 sec)
  • 18. Memory summary tables What else is worth attention? • Tables in Performance Schema memory summary global by event name memory summary by account by event name memory summary by host by event name memory summary by thread by event name memory summary by user by event name • Views in sys schema memory global total memory by thread by current bytes memory by host by current bytes memory by user by current bytes memory global by current allocated
  • 19. What did I miss? You can do even more! • MDL locks instrumentation • host cache table and all information you need to troubleshoot connection issues • Replication tables: you don’t need to parse SHOW TABLE STATUS output in your scripts anymore • Hundreds of instruments • How to tune Performance schema
  • 20. References • http://marcalff.blogspot.ru • https://github.com/MarkLeith/mysql-sys • http://dimitrik.free.fr/blog/ • http://dev.mysql.com/doc/refman/5.7/en/ performance-schema.html • https://blogs.oracle.com/svetasmirnova/tags/ performance_schema • http://www.slideshare.net/SvetaSmirnova/ performance-schema-for-mysql-troubleshooting
  • 22. ?
  • 23. The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.