SlideShare a Scribd company logo
1 of 54
Download to read offline
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL Troubleshooting with the 
Performance Schema 
Sveta Smirnova 
Senior Principal Technical Support Engineer 
Lig Isler-Turmelle 
Principle Technical Support Engineer 
MySQL Support 
September, 29, 2014 
Copyright © 2014, Oracle and/or its affiliates. AAllll rriigghhttss rreesseerrvveedd.. ||
Safe Harbor Statement 
The following 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. 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Program Agenda 
What will we teach you? 
Initial setup 
Topics 
Further studying 
1 
2 
3 
4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
The topics 
Why are your slowest statements slow? 
Which internal operations are most involved? 
What happens inside the MySQL server? 
1 
2 
3
What will we teach you? 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Performance Schema in MySQL 5.6 
• What is inside? 
– 52 tables 
– 554 instruments 
– 31 variables 
• What is it used for? 
– Overview of MySQL server performance 
• Bottlenecks in statements execution 
• Server-level and engine-level locks 
• More 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Checked with 5.6.20
With Performance Schema you can find 
• Which statements are less optimal 
• Which operations take most of the time 
• Which locks and mutexes are taken most often 
• Why users cannot connect from particular host 
• More 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Today we will discuss 
• Statement bottlenecks 
• Threads in states which can be symptom of a problem 
• Most popular mutex issues 
• How to deal with MDL locks 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Initial setup
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Default P_S settings 
• It is ON by default 
• Only global and thread instrumentation is enabled 
• All other consumers are disabled
Default P_S settings 
mysql> select * from setup_consumers; 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­+ 
| NAME | ENABLED | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­+ 
| events_stages_current | NO | 
| events_stages_history | NO | 
| events_stages_history_long | NO | 
| events_statements_current | YES | 
| events_statements_history | NO | 
... 
… 
| events_statements_history_long | NO | 
| events_waits_current | NO | 
| events_waits_history | NO | 
| events_waits_history_long | NO | 
| global_instrumentation | YES | 
| thread_instrumentation | YES | 
| statements_digest | YES | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­+ 
12 rows in set (0.00 sec) 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
We need 
• events_stages_* 
• events_statements_* 
• events_waits_* 
• Be careful! 
● They are memory and CPU intensive 
● Do not turn all of them them ON until needed
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Prepare 
mysql> update performance_schema.setup_consumers  
set enabled='yes' where name like 'events_statements_%'; 
Query OK, 2 rows affected (0.00 sec) 
Rows matched: 3 Changed: 2 Warnings: 0 
mysql> update performance_schema.setup_consumers  
set enabled='yes' where name like 'events_waits_%'; 
Query OK, 3 rows affected (0.00 sec) 
Rows matched: 3 Changed: 3 Warnings: 0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Prepare 
mysql> update performance_schema.setup_consumers  
set enabled='yes' where name like 'events_stages_%'; 
Query OK, 3 rows affected (0.04 sec) 
Rows matched: 3 Changed: 3 Warnings: 0 
mysql> update performance_schema.setup_instruments  
set enabled='yes', timed='yes' where name like 'stage/%'; 
Query OK, 108 rows affected (0.02 sec) 
Rows matched: 108 Changed: 108 Warnings: 0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Test 
mysql> use test 
Database changed 
mysql> select * from 
performance_schema. 
events_statements_currentG 
************** 1. row ************** 
THREAD_ID: 10120 
EVENT_ID: 587 
END_EVENT_ID: NULL 
EVENT_NAME: 
statement/sql/select 
SOURCE: 
mysqld.cc:956 
TIMER_START: 
990311405368794000 
TIMER_END: NULL 
TIMER_WAIT: NULL 
LOCK_TIME: 104000000 
... 
SQL_TEXT: select 
* from performance_schema. 
events_statements_current 
DIGEST: NULL 
DIGEST_TEXT: NULL 
CURRENT_SCHEMA: test 
OBJECT_TYPE: NULL 
OBJECT_SCHEMA: NULL 
OBJECT_NAME: NULL 
OBJECT_INSTANCE_BEGIN: NULL 
MYSQL_ERRNO: 0 
RETURNED_SQLSTATE: NULL 
MESSAGE_TEXT: NULL 
ERRORS: 0 
WARNINGS: 0 
ROWS_AFFECTED: 0 
... 
ROWS_SENT: 0 
ROWS_EXAMINED: 0 
CREATED_TMP_DISK_TABLES: 0 
CREATED_TMP_TABLES: 0 
SELECT_FULL_JOIN: 0 
SELECT_FULL_RANGE_JOIN: 0 
SELECT_RANGE: 0 
SELECT_RANGE_CHECK: 0 
SELECT_SCAN: 1 
SORT_MERGE_PASSES: 0 
SORT_RANGE: 0 
SORT_ROWS: 0 
SORT_SCAN: 0 
NO_INDEX_USED: 1 
NO_GOOD_INDEX_USED: 0 
NESTING_EVENT_ID: NULL 
NESTING_EVENT_TYPE: NULL 
1 row in set (0.00 sec)
Why are your slowest statements slow? 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Statements can be slow when 
• They examine more rows than return 
• They use disk instead of memory 
• They use temporary tables instead of index 
• There are more reasons 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Example 1. 
Run example query 
$mysql employees 
… 
mysql > select count(emp_no) from employees join titles 
using(emp_no) where title = 'Senior Engineer'; 
+­­­­­­­­­­­­­­­+ 
| count(emp_no) | 
+­­­­­­­­­­­­­­­+ 
| 97750 | 
+­­­­­­­­­­­­­­­+ 
1 row in set (0.80 sec)
What about queries 
that examine too many rows? 
mysql> select THREAD_ID as TID, substr(SQL_TEXT, 1, 50) as 
SQL_TEXT, ROWS_SENT as RS, ROWS_EXAMINED as RE from 
performance_schema.events_statements_history_long where 
ROWS_EXAMINED > ROWS_SENT * 10 and SQL_TEXT like 'select%'G 
*************************** 1. row *************************** 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
TID: 10124 
SQL_TEXT: select count(emp_no) from employees join titles us 
RS: 1 
RE: 397774 
...
events_statements_* 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
What else is worth attention? 
• CREATED_TMP_DISK_TABLES 
• CREATED_TMP_TABLES 
• SELECT_FULL_JOIN 
• SELECT_RANGE_CHECK 
• SELECT_SCAN 
• SORT_MERGE_PASSES 
• SORT_SCAN 
• NO_INDEX_USED 
• NO_GOOD_INDEX_USED 
•
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Example 2. 
Run example query 
mysql> select emp_no, first_name, last_name from employees join 
titles using(emp_no) where title = 'Senior Engineer'; 
… 
| 499964 | Randy | Matzov | 
| 499972 | Katsuo | Leuchs | 
| 499984 | Kaijung | Rodham | 
| 499996 | Zito | Baaz | 
| 499997 | Berhard | Lenart | 
+­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­­­+ 
97750 rows in set (0.69 sec)
What about index usage? 
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 *************************** 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
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 
...
Easier? Database sys 
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 ... `emp_no` ) 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
WHERE `title` = ? 
total_latency: 805.37 ms 
no_index_used_count: 1 
rows_sent: 1 
rows_examined: 397774 
...
events_statements_* 
• 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 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Database sys
Which internal operations are most involved? 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Why do we need to care about internal 
operations? 
• They show why a query is running and did not return results 
yet 
• Watching stages can identify issues, not related to query 
itself, but badly affecting performance 
– A query is waiting for a lock 
– Network issues slow down result set retrieval 
– Slow disk does not allow to read rows faster 
–More 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Example 3. 
Run example query 
mysql> select count(emp_no) from employees join  
salaries using(emp_no) where hire_date = from_date; 
+­­­­­­­­­­­­­­­+ 
| count(emp_no) | 
+­­­­­­­­­­­­­­­+ 
| 150291 | 
+­­­­­­­­­­­­­­­+ 
1 row in set (0.82 sec)
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 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
wait_s: 0.8170 
1 row in set (0.00 sec)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
events_stages_* 
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 (from our experience in MySQL Support Team) 
● 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'
What happens inside the MySQL server? 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Performance Schema contains a lot of 
information about what is going on inside 
• Only information, available in 5.5 
• Hard to understand 
– If you are not C programmer 
– If you don't know MySQL source code by heart 
• We will teach you 
– How you can use of this information 
–Where you can find more human-readable details 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Example 4. 
Prepare test 
mysql> create database sbtest; 
Query OK, 1 row affected (0.07 sec) 
$sysbench ­­mysql­user= 
root ­­mysql­password= 
oracle ­­test= 
oltp 
­­oltp­table­size= 
1000000 ­­db­driver= 
mysql prepare 
mysql> update performance_schema.setup_instruments set enabled='yes', 
timed='yes' where name like 'wait/%'; 
Query OK, 229 rows affected (0.02 sec) 
Rows matched: 277 Changed: 229 Warnings: 0 
mysql> truncate 
performance_schema.events_waits_summary_global_by_event_name; 
Query OK, 0 rows affected (0.00 sec)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Run some load 
$ sysbench ­­mysql­user= 
root ­­mysql­password= 
oracle ­­test= 
oltp 
­­num­threads= 
16 ­­db­driver= 
mysql run 
sysbench 0.4.12: multi­threaded 
system evaluation benchmark 
... 
Threads started! 
… 
Threads fairness: 
events (avg/stddev): 626.2500/3.23 
execution time (avg/stddev): 62.5864/0.03 
$
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
See what happened 
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 count_star desc; 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
| EVENT_NAME | COUNT_STAR | AVG_TIMER_WAIT | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
| wait/io/table/sql/handler | 4250176 | 9792048 | 
| wait/synch/mutex/sql/THD::LOCK_thd_data | 1214516 | 149382 | 
| wait/io/socket/sql/client_connection | 421690 | 20091686 | 
| wait/lock/table/sql/handler | 380912 | 497554 | 
| idle | 200081 | 10359000000 | 
| wait/synch/mutex/innodb/trx_mutex | 96441 | 84534 | 
| wait/synch/mutex/innodb/trx_undo_mutex | 50120 | 79130 | 
| wait/io/file/innodb/innodb_data_file | 3534 | 3486992374 | 
| wait/io/file/innodb/innodb_log_file | 2565 | 22204344288 | 
| wait/synch/rwlock/sql/MDL_lock::rwlock | 1 | 534224 | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
10 rows in set (0.02 sec)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
What does it mean? 
mysql> select source from 
performance_schema.events_waits_current where 
event_name='wait/io/file/innodb/innodb_log_file'; 
+­­­­­­­­­­­­­­­­­+ 
| source | 
+­­­­­­­­­­­­­­­­­+ 
| fil0fil.cc:5886 | 
| fil0fil.cc:5692 | 
+­­­­­­­­­­­­­­­­­+ 
2 rows in set (0.00 sec)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
What does it mean? 
$ cd $HOME/HOL/sample­data/ 
mysql­5.6.20 
$ cat ­n 
storage/innobase/fil/fil0fil.cc | grep ­E 
"588[[:digit:]]" 
5880 ut_a(node­> 
open); 
5881 file = node­> 
handle; 
5882 node­> 
n_pending_flushes++; 
5883 
5884 mutex_exit(&fil_system­> 
mutex); 
5885 
5886 os_file_flush(file); 
5887 
5888 mutex_enter(&fil_system­> 
mutex); 
IO
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
What does it mean? 
$ cat ­n 
storage/innobase/fil/fil0fil.cc | grep ­E 
"569[[:digit:]]" 
5690 /* Queue the aio request */ 
5691 ret = os_aio(type, mode | wake_later, node­> 
name, node­> 
handle, 
buf, 
5692 offset, len, node, message); 
5693 #endif /* UNIV_HOTBACKUP */ 
5694 ut_a(ret); 
IO 
5695 
5696 if (mode == OS_AIO_SYNC) { 
5697 /* The i/o operation is already completed when we return from 
5698 os_aio: */
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Example 5. 
One more test 
mysql> CALL sys.ps_truncate_all_tables(false); 
+­­­­­­­­­­­­­­­­­­­­­+ 
| summary | 
+­­­­­­­­­­­­­­­­­­­­­+ 
| Truncated 31 tables | 
+­­­­­­­­­­­­­­­­­­­­­+ 
1 row in set (0.02 sec) 
Query OK, 0 rows affected (0.02 sec)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
One more test 
mysql> use sbtest 
Reading table information for completion of table and 
column names 
You can turn off this feature to get a quicker startup 
with ­A 
Database changed 
mysql> alter table sbtest add key(c,pad); 
...
In parallel terminal window 
$ sysbench ­­mysql­user= 
root ­­mysql­password= 
oracle ­­test= 
oltp 
­­num­threads= 
16 ­­db­driver= 
mysql run 
sysbench 0.4.12: multi­threaded 
system evaluation benchmark 
... 
Threads started! 
… 
Threads fairness: 
events (avg/stddev): 625.7500/3.27 
execution time (avg/stddev): 141.6036/0.02 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
$
Compare with previous result 
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 desc; 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
| EVENT_NAME | COUNT_STAR | AVG_TIMER_WAIT | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­­+ 
| wait/synch/cond/sql/MDL_context::COND_wait_status | 17 | 453990564188 | 
| idle | 198053 | 56658000000 | 
| wait/io/file/innodb/innodb_log_file | 2876 | 45177967662 | 
| wait/io/file/innodb/innodb_temp_file | 3196 | 13644966830 | 
| wait/io/file/innodb/innodb_data_file | 32694 | 2927208612 | 
| wait/io/file/sql/FRM | 153 | 751453606 | 
| wait/synch/rwlock/innodb/index_tree_rw_lock | 1369436 | 83586370 | 
... 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Even more information! 
mysql> select file, count_write, total_written from sys.io_global_by_file_by_bytes  
where count_write>0 order by count_write desc; 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­+ 
| file | count_write | total_written | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­+ 
| @@datadir/sbtest/sbtest.ibd | 16830 | 479.53 MiB | 
| @@datadir/ibdata1 | 4072 | 372.44 MiB | 
| @@datadir/Innodb Merge Temp File | 1595 | 1.56 GiB | 
| @@datadir/ib_logfile0 | 1299 | 48.63 MiB | 
| @@datadir/ib_logfile1 | 140 | 2.79 MiB | 
| @@datadir/sbtest/#sql­1f8a_ 
27af.frm | 23 | 4.79 KiB | 
| @@datadir/mysql/innodb_index_stats.ibd | 1 | 16.00 KiB | 
| @@datadir/mysql/innodb_table_stats.ibd | 1 | 16.00 KiB | 
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­+ 
­­­­­­­­­­­­­­­+ 
8 rows in set (0.00 sec) 
Explains 
why ALTER 
is expensive 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Further studying
Performance Schema in MySQL 5.7 
• MDL locks hunting 
– Not only information about transaction, waiting the lock, but also 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
about one, holding the lock 
• Replication information 
• Information about transactions 
–Includes server-level 
• Memory usage 
–Database sys 
• More
MDL hunting before 5.7 
Only information about transaction waiting the lock: 
mysql> select processlist_id, mi.name, locked_by_thread_id 
from mutex_instances mi join threads on(locked_by_thread_id=thread_id) 
where locked_by_thread_id is not nullG 
******************* 1. row ******************* 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
processlist_id: 4 
name: 
wait/synch/mutex/sql/MDL_wait::LOCK_wait_status 
locked_by_thread_id: 20 
1 row in set (0.02 sec)
MDL hunting before 5.7 
Can also be found in PROCESSLIST: 
mysql> select id, state, info from information_schema.processlistG 
******************** 1. row ******************** 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
id: 4 
state: Waiting for table metadata lock 
info: alter table titles add column f1 int 
******************** 2. row ******************** 
id: 2 
state: executing 
info: select id, state, info from information_schema.processlist
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
MDL hunting in 5.7 
mysql> select processlist_id, object_type, lock_type, lock_status, source from metadata_locks join 
threads on 
(owner_thread_id=thread_id) where object_schema='employees' and object_name='titles'G 
*************************** 1. row *************************** 
processlist_id: 4 
object_type: TABLE 
lock_type: EXCLUSIVE 
lock_status: PENDING 
source: mdl.cc:3263 
*************************** 2. row *************************** 
processlist_id: 5 
object_type: TABLE 
lock_type: SHARED_READ 
lock_status: GRANTED 
source: sql_parse.cc:5707
PERFORMANCE_SCHEMA.REPLICATION_% tables 
Last_SQL_Error: Error 'Unknown table 'test.t1'' on query. Default database: 'test'. 
... 
mysql> select SERVICE_STATE, RECEIVED_TRANSACTION_SET, LAST_ERROR_NUMBER from 
replication_connection_statusG 
************************ 1. row ************************ 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
SERVICE_STATE: ON 
RECEIVED_TRANSACTION_SET: 9fa18fb7­d6f2­11e3­bc7e­a088b4923078: 
1­12 
LAST_ERROR_NUMBER: 0 
1 row in set (0.00 sec) 
mysql> select * from replication_execute_statusG 
************************ 1. row ************************ 
SERVICE_STATE: OFF 
REMAINING_DELAY: NULL 
1 row in set (0.00 sec)
MySQL Central sessions 
• MySQL’s Performance Schema: New Features in 5.6 and 5.7 
[CON2222] 
• The MySQL sys Schema [CON3751] 
• MySQL 5.7: Performance and Scalability Benchmarks [CON5066] 
• Evolving the MySQL Server Architecture [CON2387] 
• Using MySQL Workbench Performance Tools [HOL9237] 
• MySQL Query Patterns, Optimized [CON5346] 
• MySQL Replication: What’s New in 5.7 and Beyond [CON5071] 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
You will find more information at 
• In the full version of these slides 
• http://marcalff.blogspot.ru 
• http://www.markleith.co.uk/ps_helper/ 
• http://dimitrik.free.fr/blog/ 
• http://www.slideshare.net/SvetaSmirnova/performance-schema-for-mysql-troubleshooting 
• http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
You will find authors of this Lab at 
• https://twitter.com/svetsmirnova 
• https://blogs.oracle.com/svetasmirnova/ 
• https://twitter.com/lig 
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 
Thank you!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

More Related Content

What's hot

Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schemaMark Leith
 
MySQL's Performance Schema, SYS Schema and Workbench Integration
MySQL's Performance Schema, SYS Schema and Workbench IntegrationMySQL's Performance Schema, SYS Schema and Workbench Integration
MySQL's Performance Schema, SYS Schema and Workbench IntegrationMario Beck
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL PerformanceSveta Smirnova
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsMark Leith
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMark Leith
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON? Sveta Smirnova
 
Getting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise MonitorGetting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise MonitorMark Leith
 
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 SchemaTed Wennmark
 
MySQL Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and MonitoringMark Leith
 
MySQL sys schema deep dive
MySQL sys schema deep diveMySQL sys schema deep dive
MySQL sys schema deep diveMark Leith
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukValeriy Kravchuk
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 
Understanding MySql locking issues
Understanding MySql locking issuesUnderstanding MySql locking issues
Understanding MySql locking issuesOm Vikram Thapa
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
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 actionSveta Smirnova
 
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 AdministratorsSveta Smirnova
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneEnkitec
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2Alex Zaballa
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorMark Leith
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMark Leith
 

What's hot (20)

Performance schema and sys schema
Performance schema and sys schemaPerformance schema and sys schema
Performance schema and sys schema
 
MySQL's Performance Schema, SYS Schema and Workbench Integration
MySQL's Performance Schema, SYS Schema and Workbench IntegrationMySQL's Performance Schema, SYS Schema and Workbench Integration
MySQL's Performance Schema, SYS Schema and Workbench Integration
 
Troubleshooting MySQL Performance
Troubleshooting MySQL PerformanceTroubleshooting MySQL Performance
Troubleshooting MySQL Performance
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
 
Why Use EXPLAIN FORMAT=JSON?
 Why Use EXPLAIN FORMAT=JSON?  Why Use EXPLAIN FORMAT=JSON?
Why Use EXPLAIN FORMAT=JSON?
 
Getting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise MonitorGetting to Know MySQL Enterprise Monitor
Getting to Know MySQL Enterprise Monitor
 
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 Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and Monitoring
 
MySQL sys schema deep dive
MySQL sys schema deep diveMySQL sys schema deep dive
MySQL sys schema deep dive
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossuk
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 
Understanding MySql locking issues
Understanding MySql locking issuesUnderstanding MySql locking issues
Understanding MySql locking issues
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
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
 
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
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry OsborneIn Memory Database In Action by Tanel Poder and Kerry Osborne
In Memory Database In Action by Tanel Poder and Kerry Osborne
 
DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2DBA Commands and Concepts That Every Developer Should Know - Part 2
DBA Commands and Concepts That Every Developer Should Know - Part 2
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema Improvements
 

Viewers also liked

MySQL Performance - SydPHP October 2011
MySQL Performance - SydPHP October 2011MySQL Performance - SydPHP October 2011
MySQL Performance - SydPHP October 2011Graham Weldon
 
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
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimizationLouis liu
 
An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema An Overview to MySQL SYS Schema
An Overview to MySQL SYS Schema Mydbops
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMark Leith
 
MySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL ClusterMySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL ClusterShivji Kumar Jha
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
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 ReplicationShivji Kumar Jha
 
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_sysMark Leith
 
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 DevelopersZohar Elkayam
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2Morgan Tocker
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMorgan Tocker
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux SysadminsMorgan Tocker
 
MySQL: Indexing for Better Performance
MySQL: Indexing for Better PerformanceMySQL: Indexing for Better Performance
MySQL: Indexing for Better Performancejkeriaki
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaMark Leith
 
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...Making the case for write-optimized database algorithms / Mark Callaghan (Fac...
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...Ontico
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLMorgan Tocker
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 

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)
 
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
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
 
MySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL ClusterMySQL User Camp: MySQL Cluster
MySQL User Camp: MySQL Cluster
 
MySQL User Camp: GTIDs
MySQL User Camp: GTIDsMySQL User Camp: GTIDs
MySQL User Camp: GTIDs
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
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
 
MySQL Query Optimization.
MySQL Query Optimization.MySQL Query Optimization.
MySQL Query Optimization.
 
My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2My sql 5.7-upcoming-changes-v2
My sql 5.7-upcoming-changes-v2
 
MySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics ImprovementsMySQL 5.6 - Operations and Diagnostics Improvements
MySQL 5.6 - Operations and Diagnostics Improvements
 
MySQL For Linux Sysadmins
MySQL For Linux SysadminsMySQL For Linux Sysadmins
MySQL For Linux Sysadmins
 
MySQL: Indexing for Better Performance
MySQL: Indexing for Better PerformanceMySQL: Indexing for Better Performance
MySQL: Indexing for Better Performance
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
 
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...Making the case for write-optimized database algorithms / Mark Callaghan (Fac...
Making the case for write-optimized database algorithms / Mark Callaghan (Fac...
 
The InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQLThe InnoDB Storage Engine for MySQL
The InnoDB Storage Engine for MySQL
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 

Similar to MySQL Troubleshooting with the Performance Schema

MySQL Performance Schema : fossasia
MySQL Performance Schema : fossasiaMySQL Performance Schema : fossasia
MySQL Performance Schema : fossasiaMayank Prasad
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMayank Prasad
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance TuningMark Swarbrick
 
MySQL Performance Schema, Open Source India, 2015
MySQL Performance Schema, Open Source India, 2015MySQL Performance Schema, Open Source India, 2015
MySQL Performance Schema, Open Source India, 2015Mayank Prasad
 
20150110 my sql-performanceschema
20150110 my sql-performanceschema20150110 my sql-performanceschema
20150110 my sql-performanceschemaIvan Ma
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001jucaab
 
OUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLOUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLGeorgi Kodinov
 
Mysql Performance Schema - fossasia 2016
Mysql Performance Schema - fossasia 2016Mysql Performance Schema - fossasia 2016
Mysql Performance Schema - fossasia 2016Mayank Prasad
 
MySQL Webinar Series 4/4 - Manage & tune
MySQL Webinar Series 4/4 - Manage & tuneMySQL Webinar Series 4/4 - Manage & tune
MySQL Webinar Series 4/4 - Manage & tuneMark Swarbrick
 
Using MySQL Enterprise Monitor for Continuous Performance Improvement
Using MySQL Enterprise Monitor for Continuous Performance ImprovementUsing MySQL Enterprise Monitor for Continuous Performance Improvement
Using MySQL Enterprise Monitor for Continuous Performance ImprovementMark Matthews
 
Double the Performance of Oracle SOA Suite 11g? Absolutely!
Double the Performance of Oracle SOA Suite 11g? Absolutely!Double the Performance of Oracle SOA Suite 11g? Absolutely!
Double the Performance of Oracle SOA Suite 11g? Absolutely!Revelation Technologies
 
Kellyn Pot'Vin-Gorman - Awr and Ash
Kellyn Pot'Vin-Gorman - Awr and AshKellyn Pot'Vin-Gorman - Awr and Ash
Kellyn Pot'Vin-Gorman - Awr and Ashgaougorg
 
Optimizer overviewoow2014
Optimizer overviewoow2014Optimizer overviewoow2014
Optimizer overviewoow2014Mysql User Camp
 
Upgrading to my sql 8.0
Upgrading to my sql 8.0Upgrading to my sql 8.0
Upgrading to my sql 8.0Ståle Deraas
 

Similar to MySQL Troubleshooting with the Performance Schema (20)

MySQL Performance Schema : fossasia
MySQL Performance Schema : fossasiaMySQL Performance Schema : fossasia
MySQL Performance Schema : fossasia
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
MySQL Performance Schema, Open Source India, 2015
MySQL Performance Schema, Open Source India, 2015MySQL Performance Schema, Open Source India, 2015
MySQL Performance Schema, Open Source India, 2015
 
MySQL NoSQL APIs
MySQL NoSQL APIsMySQL NoSQL APIs
MySQL NoSQL APIs
 
20150110 my sql-performanceschema
20150110 my sql-performanceschema20150110 my sql-performanceschema
20150110 my sql-performanceschema
 
Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001Ebs dba con4696_pdf_4696_0001
Ebs dba con4696_pdf_4696_0001
 
OUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQLOUGLS 2016: How profiling works in MySQL
OUGLS 2016: How profiling works in MySQL
 
MySQL Quick Dive
MySQL Quick DiveMySQL Quick Dive
MySQL Quick Dive
 
Mysql Performance Schema - fossasia 2016
Mysql Performance Schema - fossasia 2016Mysql Performance Schema - fossasia 2016
Mysql Performance Schema - fossasia 2016
 
MySQL Webinar Series 4/4 - Manage & tune
MySQL Webinar Series 4/4 - Manage & tuneMySQL Webinar Series 4/4 - Manage & tune
MySQL Webinar Series 4/4 - Manage & tune
 
Using MySQL Enterprise Monitor for Continuous Performance Improvement
Using MySQL Enterprise Monitor for Continuous Performance ImprovementUsing MySQL Enterprise Monitor for Continuous Performance Improvement
Using MySQL Enterprise Monitor for Continuous Performance Improvement
 
AWR and ASH in an EM12c World
AWR and ASH in an EM12c WorldAWR and ASH in an EM12c World
AWR and ASH in an EM12c World
 
Double the Performance of Oracle SOA Suite 11g? Absolutely!
Double the Performance of Oracle SOA Suite 11g? Absolutely!Double the Performance of Oracle SOA Suite 11g? Absolutely!
Double the Performance of Oracle SOA Suite 11g? Absolutely!
 
Kellyn Pot'Vin-Gorman - Awr and Ash
Kellyn Pot'Vin-Gorman - Awr and AshKellyn Pot'Vin-Gorman - Awr and Ash
Kellyn Pot'Vin-Gorman - Awr and Ash
 
Optimizer overviewoow2014
Optimizer overviewoow2014Optimizer overviewoow2014
Optimizer overviewoow2014
 
Developer day v2
Developer day v2Developer day v2
Developer day v2
 
Thinking Beyond ORM in JPA
Thinking Beyond ORM in JPAThinking Beyond ORM in JPA
Thinking Beyond ORM in JPA
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
Upgrading to my sql 8.0
Upgrading to my sql 8.0Upgrading to my sql 8.0
Upgrading to my sql 8.0
 

More from Sveta Smirnova

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?Sveta Smirnova
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringSveta Smirnova
 
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
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersSveta Smirnova
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOpsSveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговSveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessSveta Smirnova
 
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]sSveta Smirnova
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOpsSveta Smirnova
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOpsSveta 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 ClusterSveta Smirnova
 
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 tearsSveta Smirnova
 
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...Sveta Smirnova
 
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?Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaSveta Smirnova
 
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 GaleraSveta Smirnova
 
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?Sveta Smirnova
 
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]sSveta Smirnova
 
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?Sveta Smirnova
 
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 ...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

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 

Recently uploaded (20)

React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 

MySQL Troubleshooting with the Performance Schema

  • 1. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 2. MySQL Troubleshooting with the Performance Schema Sveta Smirnova Senior Principal Technical Support Engineer Lig Isler-Turmelle Principle Technical Support Engineer MySQL Support September, 29, 2014 Copyright © 2014, Oracle and/or its affiliates. AAllll rriigghhttss rreesseerrvveedd.. ||
  • 3. Safe Harbor Statement The following 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. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda What will we teach you? Initial setup Topics Further studying 1 2 3 4
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | The topics Why are your slowest statements slow? Which internal operations are most involved? What happens inside the MySQL server? 1 2 3
  • 6. What will we teach you? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 7. Performance Schema in MySQL 5.6 • What is inside? – 52 tables – 554 instruments – 31 variables • What is it used for? – Overview of MySQL server performance • Bottlenecks in statements execution • Server-level and engine-level locks • More Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Checked with 5.6.20
  • 8. With Performance Schema you can find • Which statements are less optimal • Which operations take most of the time • Which locks and mutexes are taken most often • Why users cannot connect from particular host • More Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 9. Today we will discuss • Statement bottlenecks • Threads in states which can be symptom of a problem • Most popular mutex issues • How to deal with MDL locks Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Initial setup
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Default P_S settings • It is ON by default • Only global and thread instrumentation is enabled • All other consumers are disabled
  • 12. Default P_S settings mysql> select * from setup_consumers; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­+ | NAME | ENABLED | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­+ | events_stages_current | NO | | events_stages_history | NO | | events_stages_history_long | NO | | events_statements_current | YES | | events_statements_history | NO | ... … | events_statements_history_long | NO | | events_waits_current | NO | | events_waits_history | NO | | events_waits_history_long | NO | | global_instrumentation | YES | | thread_instrumentation | YES | | statements_digest | YES | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­+ 12 rows in set (0.00 sec) Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | We need • events_stages_* • events_statements_* • events_waits_* • Be careful! ● They are memory and CPU intensive ● Do not turn all of them them ON until needed
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Prepare mysql> update performance_schema.setup_consumers set enabled='yes' where name like 'events_statements_%'; Query OK, 2 rows affected (0.00 sec) Rows matched: 3 Changed: 2 Warnings: 0 mysql> update performance_schema.setup_consumers set enabled='yes' where name like 'events_waits_%'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Prepare mysql> update performance_schema.setup_consumers set enabled='yes' where name like 'events_stages_%'; Query OK, 3 rows affected (0.04 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> update performance_schema.setup_instruments set enabled='yes', timed='yes' where name like 'stage/%'; Query OK, 108 rows affected (0.02 sec) Rows matched: 108 Changed: 108 Warnings: 0
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Test mysql> use test Database changed mysql> select * from performance_schema. events_statements_currentG ************** 1. row ************** THREAD_ID: 10120 EVENT_ID: 587 END_EVENT_ID: NULL EVENT_NAME: statement/sql/select SOURCE: mysqld.cc:956 TIMER_START: 990311405368794000 TIMER_END: NULL TIMER_WAIT: NULL LOCK_TIME: 104000000 ... SQL_TEXT: select * from performance_schema. events_statements_current DIGEST: NULL DIGEST_TEXT: NULL CURRENT_SCHEMA: test OBJECT_TYPE: NULL OBJECT_SCHEMA: NULL OBJECT_NAME: NULL OBJECT_INSTANCE_BEGIN: NULL MYSQL_ERRNO: 0 RETURNED_SQLSTATE: NULL MESSAGE_TEXT: NULL ERRORS: 0 WARNINGS: 0 ROWS_AFFECTED: 0 ... ROWS_SENT: 0 ROWS_EXAMINED: 0 CREATED_TMP_DISK_TABLES: 0 CREATED_TMP_TABLES: 0 SELECT_FULL_JOIN: 0 SELECT_FULL_RANGE_JOIN: 0 SELECT_RANGE: 0 SELECT_RANGE_CHECK: 0 SELECT_SCAN: 1 SORT_MERGE_PASSES: 0 SORT_RANGE: 0 SORT_ROWS: 0 SORT_SCAN: 0 NO_INDEX_USED: 1 NO_GOOD_INDEX_USED: 0 NESTING_EVENT_ID: NULL NESTING_EVENT_TYPE: NULL 1 row in set (0.00 sec)
  • 17. Why are your slowest statements slow? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 18. Statements can be slow when • They examine more rows than return • They use disk instead of memory • They use temporary tables instead of index • There are more reasons Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Example 1. Run example query $mysql employees … mysql > select count(emp_no) from employees join titles using(emp_no) where title = 'Senior Engineer'; +­­­­­­­­­­­­­­­+ | count(emp_no) | +­­­­­­­­­­­­­­­+ | 97750 | +­­­­­­­­­­­­­­­+ 1 row in set (0.80 sec)
  • 20. What about queries that examine too many rows? mysql> select THREAD_ID as TID, substr(SQL_TEXT, 1, 50) as SQL_TEXT, ROWS_SENT as RS, ROWS_EXAMINED as RE from performance_schema.events_statements_history_long where ROWS_EXAMINED > ROWS_SENT * 10 and SQL_TEXT like 'select%'G *************************** 1. row *************************** Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | TID: 10124 SQL_TEXT: select count(emp_no) from employees join titles us RS: 1 RE: 397774 ...
  • 21. events_statements_* Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | What else is worth attention? • CREATED_TMP_DISK_TABLES • CREATED_TMP_TABLES • SELECT_FULL_JOIN • SELECT_RANGE_CHECK • SELECT_SCAN • SORT_MERGE_PASSES • SORT_SCAN • NO_INDEX_USED • NO_GOOD_INDEX_USED •
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Example 2. Run example query mysql> select emp_no, first_name, last_name from employees join titles using(emp_no) where title = 'Senior Engineer'; … | 499964 | Randy | Matzov | | 499972 | Katsuo | Leuchs | | 499984 | Kaijung | Rodham | | 499996 | Zito | Baaz | | 499997 | Berhard | Lenart | +­­­­­­­­+ ­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­­­+ 97750 rows in set (0.69 sec)
  • 23. What about index usage? 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 *************************** Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 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 ...
  • 24. Easier? Database sys 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 ... `emp_no` ) Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | WHERE `title` = ? total_latency: 805.37 ms no_index_used_count: 1 rows_sent: 1 rows_examined: 397774 ...
  • 25. events_statements_* • 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 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Database sys
  • 26. Which internal operations are most involved? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 27. Why do we need to care about internal operations? • They show why a query is running and did not return results yet • Watching stages can identify issues, not related to query itself, but badly affecting performance – A query is waiting for a lock – Network issues slow down result set retrieval – Slow disk does not allow to read rows faster –More Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Example 3. Run example query mysql> select count(emp_no) from employees join salaries using(emp_no) where hire_date = from_date; +­­­­­­­­­­­­­­­+ | count(emp_no) | +­­­­­­­­­­­­­­­+ | 150291 | +­­­­­­­­­­­­­­­+ 1 row in set (0.82 sec)
  • 29. 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 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | wait_s: 0.8170 1 row in set (0.00 sec)
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | events_stages_* 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 (from our experience in MySQL Support Team) ● 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'
  • 31. What happens inside the MySQL server? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 32. Performance Schema contains a lot of information about what is going on inside • Only information, available in 5.5 • Hard to understand – If you are not C programmer – If you don't know MySQL source code by heart • We will teach you – How you can use of this information –Where you can find more human-readable details Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Example 4. Prepare test mysql> create database sbtest; Query OK, 1 row affected (0.07 sec) $sysbench ­­mysql­user= root ­­mysql­password= oracle ­­test= oltp ­­oltp­table­size= 1000000 ­­db­driver= mysql prepare mysql> update performance_schema.setup_instruments set enabled='yes', timed='yes' where name like 'wait/%'; Query OK, 229 rows affected (0.02 sec) Rows matched: 277 Changed: 229 Warnings: 0 mysql> truncate performance_schema.events_waits_summary_global_by_event_name; Query OK, 0 rows affected (0.00 sec)
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Run some load $ sysbench ­­mysql­user= root ­­mysql­password= oracle ­­test= oltp ­­num­threads= 16 ­­db­driver= mysql run sysbench 0.4.12: multi­threaded system evaluation benchmark ... Threads started! … Threads fairness: events (avg/stddev): 626.2500/3.23 execution time (avg/stddev): 62.5864/0.03 $
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | See what happened 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 count_star desc; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­+ | EVENT_NAME | COUNT_STAR | AVG_TIMER_WAIT | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­+ | wait/io/table/sql/handler | 4250176 | 9792048 | | wait/synch/mutex/sql/THD::LOCK_thd_data | 1214516 | 149382 | | wait/io/socket/sql/client_connection | 421690 | 20091686 | | wait/lock/table/sql/handler | 380912 | 497554 | | idle | 200081 | 10359000000 | | wait/synch/mutex/innodb/trx_mutex | 96441 | 84534 | | wait/synch/mutex/innodb/trx_undo_mutex | 50120 | 79130 | | wait/io/file/innodb/innodb_data_file | 3534 | 3486992374 | | wait/io/file/innodb/innodb_log_file | 2565 | 22204344288 | | wait/synch/rwlock/sql/MDL_lock::rwlock | 1 | 534224 | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­+ 10 rows in set (0.02 sec)
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | What does it mean? mysql> select source from performance_schema.events_waits_current where event_name='wait/io/file/innodb/innodb_log_file'; +­­­­­­­­­­­­­­­­­+ | source | +­­­­­­­­­­­­­­­­­+ | fil0fil.cc:5886 | | fil0fil.cc:5692 | +­­­­­­­­­­­­­­­­­+ 2 rows in set (0.00 sec)
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | What does it mean? $ cd $HOME/HOL/sample­data/ mysql­5.6.20 $ cat ­n storage/innobase/fil/fil0fil.cc | grep ­E "588[[:digit:]]" 5880 ut_a(node­> open); 5881 file = node­> handle; 5882 node­> n_pending_flushes++; 5883 5884 mutex_exit(&fil_system­> mutex); 5885 5886 os_file_flush(file); 5887 5888 mutex_enter(&fil_system­> mutex); IO
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | What does it mean? $ cat ­n storage/innobase/fil/fil0fil.cc | grep ­E "569[[:digit:]]" 5690 /* Queue the aio request */ 5691 ret = os_aio(type, mode | wake_later, node­> name, node­> handle, buf, 5692 offset, len, node, message); 5693 #endif /* UNIV_HOTBACKUP */ 5694 ut_a(ret); IO 5695 5696 if (mode == OS_AIO_SYNC) { 5697 /* The i/o operation is already completed when we return from 5698 os_aio: */
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Example 5. One more test mysql> CALL sys.ps_truncate_all_tables(false); +­­­­­­­­­­­­­­­­­­­­­+ | summary | +­­­­­­­­­­­­­­­­­­­­­+ | Truncated 31 tables | +­­­­­­­­­­­­­­­­­­­­­+ 1 row in set (0.02 sec) Query OK, 0 rows affected (0.02 sec)
  • 40. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | One more test mysql> use sbtest Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with ­A Database changed mysql> alter table sbtest add key(c,pad); ...
  • 41. In parallel terminal window $ sysbench ­­mysql­user= root ­­mysql­password= oracle ­­test= oltp ­­num­threads= 16 ­­db­driver= mysql run sysbench 0.4.12: multi­threaded system evaluation benchmark ... Threads started! … Threads fairness: events (avg/stddev): 625.7500/3.27 execution time (avg/stddev): 141.6036/0.02 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | $
  • 42. Compare with previous result 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 desc; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­+ | EVENT_NAME | COUNT_STAR | AVG_TIMER_WAIT | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­­+ | wait/synch/cond/sql/MDL_context::COND_wait_status | 17 | 453990564188 | | idle | 198053 | 56658000000 | | wait/io/file/innodb/innodb_log_file | 2876 | 45177967662 | | wait/io/file/innodb/innodb_temp_file | 3196 | 13644966830 | | wait/io/file/innodb/innodb_data_file | 32694 | 2927208612 | | wait/io/file/sql/FRM | 153 | 751453606 | | wait/synch/rwlock/innodb/index_tree_rw_lock | 1369436 | 83586370 | ... Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 43. Even more information! mysql> select file, count_write, total_written from sys.io_global_by_file_by_bytes where count_write>0 order by count_write desc; +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­+ | file | count_write | total_written | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­+ | @@datadir/sbtest/sbtest.ibd | 16830 | 479.53 MiB | | @@datadir/ibdata1 | 4072 | 372.44 MiB | | @@datadir/Innodb Merge Temp File | 1595 | 1.56 GiB | | @@datadir/ib_logfile0 | 1299 | 48.63 MiB | | @@datadir/ib_logfile1 | 140 | 2.79 MiB | | @@datadir/sbtest/#sql­1f8a_ 27af.frm | 23 | 4.79 KiB | | @@datadir/mysql/innodb_index_stats.ibd | 1 | 16.00 KiB | | @@datadir/mysql/innodb_table_stats.ibd | 1 | 16.00 KiB | +­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+ ­­­­­­­­­­­­­+ ­­­­­­­­­­­­­­­+ 8 rows in set (0.00 sec) Explains why ALTER is expensive Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Further studying
  • 45. Performance Schema in MySQL 5.7 • MDL locks hunting – Not only information about transaction, waiting the lock, but also Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | about one, holding the lock • Replication information • Information about transactions –Includes server-level • Memory usage –Database sys • More
  • 46. MDL hunting before 5.7 Only information about transaction waiting the lock: mysql> select processlist_id, mi.name, locked_by_thread_id from mutex_instances mi join threads on(locked_by_thread_id=thread_id) where locked_by_thread_id is not nullG ******************* 1. row ******************* Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | processlist_id: 4 name: wait/synch/mutex/sql/MDL_wait::LOCK_wait_status locked_by_thread_id: 20 1 row in set (0.02 sec)
  • 47. MDL hunting before 5.7 Can also be found in PROCESSLIST: mysql> select id, state, info from information_schema.processlistG ******************** 1. row ******************** Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | id: 4 state: Waiting for table metadata lock info: alter table titles add column f1 int ******************** 2. row ******************** id: 2 state: executing info: select id, state, info from information_schema.processlist
  • 48. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MDL hunting in 5.7 mysql> select processlist_id, object_type, lock_type, lock_status, source from metadata_locks join threads on (owner_thread_id=thread_id) where object_schema='employees' and object_name='titles'G *************************** 1. row *************************** processlist_id: 4 object_type: TABLE lock_type: EXCLUSIVE lock_status: PENDING source: mdl.cc:3263 *************************** 2. row *************************** processlist_id: 5 object_type: TABLE lock_type: SHARED_READ lock_status: GRANTED source: sql_parse.cc:5707
  • 49. PERFORMANCE_SCHEMA.REPLICATION_% tables Last_SQL_Error: Error 'Unknown table 'test.t1'' on query. Default database: 'test'. ... mysql> select SERVICE_STATE, RECEIVED_TRANSACTION_SET, LAST_ERROR_NUMBER from replication_connection_statusG ************************ 1. row ************************ Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | SERVICE_STATE: ON RECEIVED_TRANSACTION_SET: 9fa18fb7­d6f2­11e3­bc7e­a088b4923078: 1­12 LAST_ERROR_NUMBER: 0 1 row in set (0.00 sec) mysql> select * from replication_execute_statusG ************************ 1. row ************************ SERVICE_STATE: OFF REMAINING_DELAY: NULL 1 row in set (0.00 sec)
  • 50. MySQL Central sessions • MySQL’s Performance Schema: New Features in 5.6 and 5.7 [CON2222] • The MySQL sys Schema [CON3751] • MySQL 5.7: Performance and Scalability Benchmarks [CON5066] • Evolving the MySQL Server Architecture [CON2387] • Using MySQL Workbench Performance Tools [HOL9237] • MySQL Query Patterns, Optimized [CON5346] • MySQL Replication: What’s New in 5.7 and Beyond [CON5071] Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 51. You will find more information at • In the full version of these slides • http://marcalff.blogspot.ru • http://www.markleith.co.uk/ps_helper/ • http://dimitrik.free.fr/blog/ • http://www.slideshare.net/SvetaSmirnova/performance-schema-for-mysql-troubleshooting • http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 52. You will find authors of this Lab at • https://twitter.com/svetsmirnova • https://blogs.oracle.com/svetasmirnova/ • https://twitter.com/lig Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 53. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Thank you!
  • 54. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |