SlideShare a Scribd company logo
<Insert Picture Here>

Performance Schema for MySQL troubleshooting
Sveta Smirnova
Senior Principal Technical MySQL Support Engineer
Content
•
•
•
•
•
•
•
•
•

History of Performance Schema
Tables for DBA
Tables for developers
Other tables
Tools
Performance and tests
Options
Information sources
Conclusion
History of Performance Schema
•
•
•
•

First version: in MySQL 5.5
17 tables
Useful mostly for developers of MySQL code
Tools for
– Mutexes
– Locks

• Required good knowledge of MySQL code
Kinds of tables
• Settings
– _setup
– _instances

• Events
– events_waits_

• Digests
• History
• Other
Version 5.6 turned its face to DBA
• More features
• 52 tables
• New tables, very useful
for DBA
• Knowledge of MySQL
source code is not a
requirement anymore

*That's me talking at Devconf 2012 about how I am,
as MySQL Support engineer,
is happy with new features in Performance Schema

*
Tables for DBA
• events_statements_*
• events_stages_*
• Connection
events_statements_*
• Statements
– statement/sql
• statement/sql/delete
• statement/sql/select

• Commands
– COM_PING, COM_QUIT, ...
– statement/com
• statement/com/Ping
• statement/com/Quit

• Errors
– statement/sql/error
– statement/com/Error
events_statements_*:
which queries finished with an error
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select THREAD_ID, substr(SQL_TEXT, 1, 20),
MYSQL_ERRNO from  events_statements_history_long where 
MYSQL_ERRNO != 0;
+­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
| THREAD_ID | substr(SQL_TEXT, 1, 20) | MYSQL_ERRNO |
+­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
|        18 | select from * event_    |        1064 |
|        18 | select * from  event    |        1146 |
|        18 | select * from  event    |        1146 |
|        18 | select THREAD_ID, SQ    |        1146 |
+­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
4 rows in set (0.00 sec)
events_statements_*:
queries which need to be optimized
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select THREAD_ID as TID, substr(SQL_TEXT, 1, 20) 
as SQL_TEXT, ROWS_SENT as RS, ROWS_EXAMINED as RE from  
events_statements_history_long where ROWS_EXAMINED > 
ROWS_SENT * 10 limit 5;
+­­­­­+­­­­­­­­­­­­­­­­­­­­­­+­­­­+­­­­­+
| TID | SQL_TEXT             | RS | RE  |
+­­­­­+­­­­­­­­­­­­­­­­­­­­­­+­­­­+­­­­­+
|  18 | select THREAD_ID, SQ |  4 | 147 |
|  18 | select THREAD_ID, su |  4 | 148 |
|  18 | select THREAD_ID, su |  4 | 152 |
|  18 | select THREAD_ID, su |  4 | 153 |
|  18 | select THREAD_ID, su |  1 | 154 |
+­­­­­+­­­­­­­­­­­­­­­­­­­­­­+­­­­+­­­­­+
5 rows in set (0.00 sec)
events_statements_*: what also 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
events_statements_*: ps_helper view
•
•
•
•
•
•
•

http://www.markleith.co.uk/ps_helper/
View: statement_analysis
View: statements_with_runtimes_in_95th_percentile
View: statements_with_temp_tables
View: statements_with_sorting
View: statements_with_full_table_scans
View: statements_with_errors_or_warnings
event_stages_*
• Same information which you see in table
INFORMATION_SCHEMA.PROCESSLIST or SHOW
PROCESSLIST output
–
–
–
–

init
executing
Opening tables
...

• Replacement of SHOW PROFILE
• Only server-level
• No information from storage engine in this table!
event_stages_*:
«Sending data» for more than 10 seconds
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select events_stages_history_long.event_name,
sql_text,  
events_stages_history_long.timer_wait/1000000000000 
wait_s from events_stages_history_long join 
events_statements_history_long on 
(events_stages_history_long.nesting_event_id = 
events_statements_history_long.event_id) where 
events_stages_history_long.EVENT_NAME like '%Sending 
data' and rows_sent < 10000000 and 
events_stages_history_long.timer_wait > 10*1000000000000 
order by events_stages_history_long.timer_wait descG
************************ 1. row ************************
event_name: stage/sql/Sending data
  sql_text: insert into test.t2 select * from test.t2 
    wait_s: 243.5235
1 rows in set (0.01 sec)
event_stages_*:
other operations which can run slow
• 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 my Support 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'
event_stages_*: longest queries
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select eshl.event_name, sql_text,
eshl.timer_wait/1000000000000 wait_s from 
events_stages_history_long eshl join 
events_statements_history_long esthl on 
(eshl.nesting_event_id = esthl.event_id) where 
eshl.timer_wait > 10*1000000000000G
************************ 1. row ************************
event_name: stage/sql/copy to tmp table
  sql_text: alter table t2 engine=innodb
    wait_s: 186.8122
************************ 2. row ************************
event_name: stage/sql/Waiting for table metadata lock
  sql_text: insert into t2 select * from t2 LIMIT 10
    wait_s: 46.6250
2 rows in set (0.01 sec)
event_stages_*: joins
• NESTING_EVENT_ID
– Statement
– Wait
– Stage

• EVENT_ID

events_statements
EVENT_ID
events_stages
NESTING_EVENT_ID
events_stages
NESTING_EVENT_ID
events_stages
NESTING_EVENT_ID
Connection Tables: accounts
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select user, host, current_connections as cur, 
total_connections as total from accounts;
+­­­­­­+­­­­­­­­­­­+­­­­­+­­­­­­­+
| user | host      | cur | total |
+­­­­­­+­­­­­­­­­­­+­­­­­+­­­­­­­+
| foo  | localhost |   0 |     3 |
| root | localhost |   1 |     3 |
| NULL | NULL      |  14 |    17 |
+­­­­­­+­­­­­­­­­­­+­­­­­+­­­­­­­+
3 rows in set (0.01 sec)
Connection Tables: users, hosts
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select user, current_connections as cur, 
total_connections as total from users;
+­­­­­­+­­­­­+­­­­­­­+
| user | cur | total |
+­­­­­­+­­­­­+­­­­­­­+
| root |   1 |     3 |
| NULL |  14 |    17 |
| foo  |   0 |     3 |
+­­­­­­+­­­­­+­­­­­­­+
3 rows in set (0.00 sec)
mysql> select host, current_connections as cur, 
total_connections as total from hosts;
+­­­­­­­­­­­+­­­­­+­­­­­­­+
| host      | cur | total |
+­­­­­­­­­­­+­­­­­+­­­­­­­+
| NULL      |  14 |    17 |
| localhost |   1 |     6 |
+­­­­­­­­­­­+­­­­­+­­­­­­­+
2 rows in set (0.01 sec)
Connection Attribute Tables
●
●
●

mysql_init(&mysql);
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_RESET, 0);

●
●
●
●
●
●
●
●

mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD,
 "program", "Devconf2013");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, 
"author", "Sveta Smirnova");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, 
"session", "MySQL Performance Schema");

●
●
●
●

mysql_real_connect(&mysql, "127.0.0.1", "root", "",
"test", 13000, NULL, 0);
Connection Attribute Tables
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select ATTR_NAME, ATTR_VALUE from 
performance_schema.session_account_connect_attrs where 
processlist_id != @@pseudo_thread_id;
+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+
| ATTR_NAME       | ATTR_VALUE               |
+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+
| _os             | Linux                    |
| _client_name    | libmysql                 |
| _pid            | 4729                     |
| program_name    | Devconf2013              |
| _platform       | x86_64                   |
| session         | MySQL Performance Schema |
| author          | Sveta Smirnova           |
| _client_version | 5.6.12                   |
+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­+
8 rows in set (0.01 sec)
Connection Attribute Tables: foreigners prohibited!
●
●
●
●
●
●
●
●
●
●
●

mysql> select PROCESSLIST_ID as PID, ATTR_NAME, 
ATTR_VALUE from session_account_connect_attrs where 
attr_name='program_name';
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
| PID | ATTR_NAME    | ATTR_VALUE  |
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
|   9 | program_name | mysql       |
|  13 | program_name | Devconf2013 |
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
2 rows in set (0.00 sec)
Connection Attribute Tables: foreigners prohibited!
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select PROCESSLIST_ID as PID, ATTR_NAME,  
ATTR_VALUE from session_account_connect_attrs where  
attr_name='program_name' union select PROCESSLIST_ID as 
PID, 'program_name' as ATTR_NAME, 
sum(if(attr_name='program_name', 1, 0)) as ATTR_VALUE 
from session_account_connect_attrs group by 
processlist_id having(ATTR_VALUE=0);
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
| PID | ATTR_NAME    | ATTR_VALUE  |
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
|   9 | program_name | mysql       |
|  13 | program_name | Devconf2013 |
|  21 | program_name | 0           |
+­­­­­+­­­­­­­­­­­­­­+­­­­­­­­­­­­­+
3 rows in set (0.01 sec)
host_cache
• Content of DNS cache
• Errors from
–
–
–
–

Name server
Connection
Authentication
max_connect_errors, max_user_errors, etc.

• Your first assistant in case of connection issue
threads
• Two kinds of THREADS
– Background
– Foreground

• Fields
– THREAD_ID
• Internal thread id
– PROCESSLIST_ID
• id, observable in the SHOW PROCESSLIST output
– NAME
• Instrument
– PARENT_THREAD_ID
• Internal id of the parent thread
– PROCESSLIST_*
• Only for для FOREGROUND threads
threads
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select * from threads where type = 'foreground'G
************************ 1. row ************************
          THREAD_ID: 16
               NAME: thread/sql/one_connection
               TYPE: FOREGROUND
     PROCESSLIST_ID: 1
   PROCESSLIST_USER: root
   PROCESSLIST_HOST: localhost
     PROCESSLIST_DB: performance_schema
PROCESSLIST_COMMAND: Query
   PROCESSLIST_TIME: 0
  PROCESSLIST_STATE: Sending data
   PROCESSLIST_INFO: select * from threads where type = 
'foreground'
   PARENT_THREAD_ID: 1
               ROLE: NULL
       INSTRUMENTED: YES
1 row in set (0.00 sec)
threads
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select name from threads where type='background';
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| name                                   |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
| thread/sql/main                        |
| thread/innodb/io_handler_thread        |
| thread/innodb/io_handler_thread        |
| thread/innodb/io_handler_thread        |
| thread/innodb/io_handler_thread        |
| thread/innodb/io_handler_thread        |
| thread/innodb/io_handler_thread        |
| thread/innodb/srv_lock_timeout_thread  |
| thread/innodb/srv_error_monitor_thread |
| thread/innodb/srv_monitor_thread       |
| thread/innodb/srv_master_thread        |
| thread/innodb/srv_purge_thread         |
| thread/innodb/page_cleaner_thread      |
| thread/sql/signal_handler              |
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+
14 rows in set (0.00 sec)
events_waits_*
• EVENT_NAME
– wait/synch/rwlock/innodb/dict_operation_lock

• SOURCE
– Line of the source code

• OPERATION
– Kind of operation: read, lock, write
event_waits_*
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select e.EVENT_NAME, e.SOURCE, e.OPERATION, 
t.PROCESSLIST_INFO from events_waits_current e join 
threads t using(thread_id) where type='foreground' and 
processlist_id != 1G
************************ 1. row ************************
      EVENT_NAME:
 wait/synch/cond/sql/Item_func_sleep::cond
          SOURCE: item_func.cc:4212
       OPERATION: timed_wait
PROCESSLIST_INFO: select sleep(100) from t1
1 row in set (0.01 sec)
wait/synch/cond/sql/Item_func_sleep::cond
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

$ cat ­n  sql/item_func.cc | head ­n 4220 | tail ­n 35
4186
4187 /**
4188   Wait for a given condition to be signaled.
4189
4190   @param cond   The condition variable to wait on.
4191   @param mutex  The associated mutex.
4192
4193   @remark The absolute timeout is preserved across 
calls.
4194
4195   @retval return value from mysql_cond_timedwait
4196 */
4197
wait/synch/cond/sql/Item_func_sleep::cond
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

4198 int Interruptible_wait::wait(mysql_cond_t
*cond, mysql_mutex_t *mutex)
4199 {
4200   int error;
4201   struct timespec timeout;
4202
4203   while (1)
4204   {
4205     /* Wait for a fixed interval. */
4206     set_timespec_nsec(timeout, 
m_interrupt_interval);
4207
4208     /* But only if not past the absolute 
timeout. */
4209     if (cmp_timespec(timeout, m_abs_timeout) > 0)
4210       timeout= m_abs_timeout;
wait/synch/cond/sql/Item_func_sleep::cond
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

  
4212     error= mysql_cond_timedwait(cond, mutex, 
&timeout);
4213     if (error == ETIMEDOUT || error == ETIME)
4214     {
4215       /* Return error if timed out or connection 
is broken. */
4216       if (!cmp_timespec(timeout, m_abs_timeout) || 
!m_thd­>is_connected())
4217         break;
4218     }
4219     /* Otherwise, propagate status to the caller. 
*/
4220     else
Query statistics
●
●
●
●
●

mysql> UPDATE performance_schema.threads SET 
instrumented = 'NO'; 
Query OK, 15 rows affected (0.04 sec)
Rows matched: 15  Changed: 15  Warnings: 0

●
●

Open new connection

●
●

mysql> truncate events_waits_history_long;               
                                                         
                                                     
Query OK, 0 rows affected (0.00 sec)

●
●

In new connection

●
●
●
●
●

mysql2> create temporary table norepl_t1 engine=myisam
 select amount, price, money, id_product from test;
Query OK, 262144 rows affected (4.76 sec)
Records: 262144  Duplicates: 0  Warnings: 0
Query events_waits_history_long
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

mysql> select e.EVENT_NAME, e.SOURCE, e.OPERATION,
 count(*) as cnt from events_waits_history_long e join 
threads t using(thread_id) where type='foreground' and 
processlist_id not in (1, @@pseudo_thread_id) group by 
e.EVENT_NAME, e.SOURCE, e.OPERATION order by cnt descG
************************ 1. row ************************
EVENT_NAME: wait/synch/mutex/innodb/lock_mutex
    SOURCE: lock0lock.cc:5529
 OPERATION: lock
       cnt: 1428
************************ 2. row ************************
EVENT_NAME: wait/synch/mutex/innodb/lock_mutex
    SOURCE: lock0lock.cc:6362
 OPERATION: lock
       cnt: 1428
Query events_waits_history_long
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

************************ 3. row ************************
EVENT_NAME: wait/synch/mutex/innodb/trx_sys_mutex
    SOURCE: lock0lock.cc:5530
 OPERATION: lock
       cnt: 1428
************************ 4. row ************************
EVENT_NAME: wait/synch/mutex/innodb/trx_mutex
    SOURCE: lock0lock.cc:2133
 OPERATION: lock
       cnt: 1423
************************ 5. row ************************
EVENT_NAME: wait/io/table/sql/handler
    SOURCE: handler.cc:2627
 OPERATION: fetch
       cnt: 1423
Query events_waits_history_long
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●

************************ 6. row ************************
EVENT_NAME: wait/synch/mutex/innodb/lock_mutex
    SOURCE: lock0lock.cc:6050
 OPERATION: lock
       cnt: 1421
************************ 7. row ************************
EVENT_NAME: wait/synch/mutex/innodb/trx_sys_mutex
    SOURCE: trx0sys.ic:431
 OPERATION: lock
       cnt: 1421
************************ 8. row ************************
EVENT_NAME: wait/synch/mutex/innodb/buf_pool_mutex
    SOURCE: buf0buf.ic:887
 OPERATION: lock
       Cnt: 6
...
Which kind of events can we examine?
• 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/
• sql, InnoDB, MyISAM
ps_helper
• All VIEWs work for MySQL 5.5
–
–
–
–
–
–
–

latest_file_io
top_io_by_file
top_io_by_thread
top_global_consumers_by_avg_latency
top_global_consumers_by_total_latency
top_global_io_consumers_by_latency
top_global_io_consumers_by_bytes_usage

• There are few views for 5.6 which use digest tables
*_instances tables
• file_instances
– Opened files

• socket_instances
– Connections

• cond_instances
• rwlock_instances
– select * from rwlock_instances where  
READ_LOCKED_BY_COUNT > 0;
– select * from rwlock_instances where  
WRITE_LOCKED_BY_THREAD_ID > 0;

• mutex_instances
– LOCKED_BY_THREAD_ID
Digests
•
•
•
•
•
•
•
•

events_stages_*
events_statements_*
events_waits_*
file_*
objects_*
socket_*
table_io_waits_*
table_lock_waits_*
Digests: events_stages_summary_*
• events_stages_summary_by_account_by_event_name
– Helps to find an account which performs problematic queries

• events_stages_summary_by_host_by_event_name
• events_stages_summary_by_user_by_event_name
– Same, but sorted by host and user name

• events_stages_summary_by_thread_by_event_name
– Easy to find out what makes troubles on your server right now
– Since statistics is saved for some time you can find it and after the
problem stopped to show up

• events_stages_summary_by_global_by_event_name
– Global stats by event name
– Does not indicate user, host, account and thread
•
•
•
•
•

Digests: events_statements_summary_*
events_statements_summary_by_account_by_event_name
events_statements_summary_by_host_by_event_name
events_statements_summary_by_user_by_event_name
events_statements_summary_by_thread_by_event_name
events_statements_summary_global_by_event_name
– Same as stages, but stats are taken from tables events_statements_*

• events_statements_summary_by_digest
– Stats by digest field:
• 42b93d481e96b9c9b4049b9407900194
• Query written as SELECT fname FROM tname WHERE fname = ?
– For example, you can find all statements which create temporary tables by
querying this table
Digests: events_waits_summary_*
•
•
•
•
•

events_waits_summary_by_account_by_event_name
events_waits_summary_by_host_by_event_name
events_waits_summary_by_thread_by_event_name
events_waits_summary_by_user_by_event_name
events_waits_summary_global_by_event_name
– Similar to events_stages_* digests

• events_waits_summary_by_instance
– By OBJECT_INSTANCE_BEGIN field
Other digests
• file_summary_by_event_name
– Does not show file name!

•
•
•
•
•

file_summary_by_instance
objects_summary_global_by_type
socket_summary_by_event_name
socket_summary_by_event_name
socket_summary_by_instance
– By OBJECT_INSTANCE_BEGIN field

• table_io_waits_summary_by_index_usage
• table_io_waits_summary_by_table
• table_lock_waits_summary_by_table
Digests
• WHERE COUNT_STAR > 0
• Sort or query by an operation you are interested in
• Sort by COUNT_STAR
Performance
Performance: version 5.5
• Performance Schema is OFF by default
• Noticeable performance issues
– Up to 7% in case of RO load
– Up to 20% in case of RW load
– Numbers based on tests by Dimitri Kravtchuk
(http://dimitrik.free.fr/blog/archives/2010/05/mysql-performance-using-performance-schema.html )

• No performance loss if turned off
Performance: version 5.6
• Performance Schema is ON by default
• Performance loss can happen, but not big
– Not more than 5% for most setups, likely near 0
– Maximum up to 10% in case if all instrumentations are turned ON
– Numbers based on tests by Dimitri Kravtchuk
(http://dimitrik.free.fr/blog/archives/2012/06/mysql-performance-pfs-overhead-in-56.html)

• global_instrumentation
– Minimal overhead

• Detailed instrumentation
– Noticeable overhead

• History tables
– minimal overhead
How P_S uses OS and hardware resources
• Memory
–
–
–
–

Allocated at the server startup
Freed when MySQL server is stopped
Uses arrays instead of linked lists
mysql> show engine performance_schema status;
+­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+
| Type               | Name                      | Status   |
+­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+
...
| performance_schema | performance_schema.memory | 68024616 |
+­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­­­­+

• CPU
– Depends from number of instruments
– More instruments — higher load
Options
What, where and when to setup
• At compile time
• At the server startup
– Options in my.cnf
– All options are static

• Runtime
– setup_* tables

• What can you tune?
– Look for tables documentation
Configuration options
• performance_schema = ON|OFF
– Is it On or Off?

• performance_schema_%_size
– Size of history tables
– Size of instrumented objects

• performance_schema_max_%_classes
– Maximum number of cond|fle|io|% instruments

• performance_schema_max_%_instances
– Maximum number of cond|fle|io|% objects
Configuration options
• performance_schema_consumer_TABLE_NAME
– performance_schema_consumer_events_stages_current
– performance_schema_consumer_events_waits_current
– ...

• Turns instrumentations On of Off
– OFF, FALSE, 0
– ON, TRUE, 1

• setup_consumers table
– update setup_consumers set enabled='no' 
where name='events_stages_current';
Tables setup_actors and setup_objects
• setup_actors
–
–
–
–

Which user threads to monitor
DELETE , then INSERT
UPDATE not allowed
insert into setup_actors values('%', 'sveta', '%');
• Only for user sveta

• setup_objects
– Which objects to monitor
– update setup_objects set enabled='no' 
where object_schema='%';
– insert into setup_objects values 
('TABLE', 'test', 't1', 'YES', 'YES');
•
•
•
•

setup_instruments table
Detailed setup of instruments
549 instruments in the standard distribution*
update setup_instruments set enabled='no';
update setup_instruments set enabled='yes' 
where name like 'statement%';

*Written at June, 2013. Subject to change.
Timers
●

●

Values for your machine

●
●
●
●
●
●
●
●
●
●
●
●

mysql> select * from performance_timers;
+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+
| TIMER_NAME  | TIMER_FREQUENCY | TIMER_RESOLUTION | TIMER_OVERHEAD |
+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+
| CYCLE       |      2592796019 |                1 |             18 |
| NANOSECOND  |      1000000000 |                1 |             45 |
| MICROSECOND |         1000000 |                1 |             48 |
| MILLISECOND |            1037 |                1 |             54 |
| TICK        |             103 |                1 |            547 |
+­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­­­+­­­­­­­­­­­­­­­­+
5 rows in set (0.00 sec)

●

●
●
●

How to tune:
mysql> update setup_timers set timer_name='tick' 
where name = 'stage';
What happens inside Performance Schema?
●
●
●
●
●
●
●
●
●
●

mysql> show global status like 'perf%';
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­
+
| Variable_name                                 | Value 
|
+­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­+­­­­­­­
+
| Performance_schema_accounts_lost              | 0     
|
| Performance_schema_cond_classes_lost          | 0     
|
| Performance_schema_cond_instances_lost        | 0     
|
| Performance_schema_digest_lost                | 0     
|
...

●
●

If Value is not null — your *_size options are too small
•
•
•
•
•

What happens inside Performance Schema?
SHOW ENGINE PERFORMANCE_SCHEMA STATUS;
Contains information about memory usage
Table_name.attribute
(Internal_buffer).attribute
*.size, *.row_size
– Not-configurable, for example, size of a table row

• *.count, *.row_count
– Configurable with help of options

• *.memory
– size * count
– events_waits_history_long.memory
– performance_schema.memory
Where to find information?
• http://www.markleith.co.uk/ps_helper/
• http://www.drdobbs.com/database/detailed-profiling-of-sql-activity-in-my/240154959

• http://marcalff.blogspot.ru
• http://dimitrik.free.fr/blog/
• http://dev.mysql.com/doc/refman/5.6/en/performance-schema.html
Conclusion
• Performance schema — wonderful tool for a DBA
when she needs to troubleshoot performance issue
• You can configure it online: without server restart
• Allows very detailed setup
• Always tune it for your own needs!
• Don't instrument everything: use it for operations you
are interested in only
?
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 (20)

PDF
MySQL Administrator 2021 - 네오클로바
NeoClova
 
PDF
Percona xtrabackup - MySQL Meetup @ Mumbai
Nilnandan Joshi
 
PDF
Maxscale_메뉴얼
NeoClova
 
PDF
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
SANG WON PARK
 
PDF
MariaDB 10.5 binary install (바이너리 설치)
NeoClova
 
PDF
PostgreSQL WAL for DBAs
PGConf APAC
 
PDF
MariaDB Administrator 교육
Sangmo Kim
 
PPTX
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
ScyllaDB
 
PDF
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
SeungYong Oh
 
PDF
5 Steps to PostgreSQL Performance
Command Prompt., Inc
 
PPT
Linux monitoring and Troubleshooting for DBA's
Mydbops
 
PDF
MariaDB 마이그레이션 - 네오클로바
NeoClova
 
PDF
MySQL 상태 메시지 분석 및 활용
I Goo Lee
 
PDF
Advanced Percona XtraDB Cluster in a nutshell... la suite
Kenny Gryp
 
PPTX
PostgreSQL and JDBC: striving for high performance
Vladimir Sitnikov
 
PPTX
Linux の hugepage の開発動向
Naoya Horiguchi
 
DOCX
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
NeoClova
 
PDF
ksqlDB로 실시간 데이터 변환 및 스트림 처리
confluent
 
PPT
Oracle backup and recovery
Yogiji Creations
 
MySQL Administrator 2021 - 네오클로바
NeoClova
 
Percona xtrabackup - MySQL Meetup @ Mumbai
Nilnandan Joshi
 
Maxscale_메뉴얼
NeoClova
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
SANG WON PARK
 
MariaDB 10.5 binary install (바이너리 설치)
NeoClova
 
PostgreSQL WAL for DBAs
PGConf APAC
 
MariaDB Administrator 교육
Sangmo Kim
 
Materialized Views and Secondary Indexes in Scylla: They Are finally here!
ScyllaDB
 
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
SeungYong Oh
 
5 Steps to PostgreSQL Performance
Command Prompt., Inc
 
Linux monitoring and Troubleshooting for DBA's
Mydbops
 
MariaDB 마이그레이션 - 네오클로바
NeoClova
 
MySQL 상태 메시지 분석 및 활용
I Goo Lee
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Kenny Gryp
 
PostgreSQL and JDBC: striving for high performance
Vladimir Sitnikov
 
Linux の hugepage の開発動向
Naoya Horiguchi
 
Keepalived+MaxScale+MariaDB_운영매뉴얼_1.0.docx
NeoClova
 
ksqlDB로 실시간 데이터 변환 및 스트림 처리
confluent
 
Oracle backup and recovery
Yogiji Creations
 

Viewers also liked (20)

PDF
The MySQL SYS Schema
Mark Leith
 
PDF
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
PDF
The InnoDB Storage Engine for MySQL
Morgan Tocker
 
PPT
MySQL Atchitecture and Concepts
Tuyen Vuong
 
PPT
Explain that explain
Fabrizio Parrella
 
PDF
Performance Tuning Best Practices
webhostingguy
 
KEY
Inside PyMongo - MongoNYC
Mike Dirolf
 
PDF
InnoDB Locking Explained with Stick Figures
Karwin Software Solutions LLC
 
PDF
InnoDB architecture and performance optimization (Пётр Зайцев)
Ontico
 
PDF
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
 
PDF
How to analyze and tune sql queries for better performance percona15
oysteing
 
PDF
Performance Schema and Sys Schema in MySQL 5.7
Mark Leith
 
PDF
Performance Schema in MySQL (Danil Zburivsky)
Ontico
 
PDF
MySQL Troubleshooting with the Performance Schema
Sveta Smirnova
 
PDF
The MySQL Performance Schema & New SYS Schema
Ted Wennmark
 
KEY
MySQL Performance - SydPHP October 2011
Graham Weldon
 
PDF
MySQL EXPLAIN Explained-Norvald H. Ryeng
郁萍 王
 
PDF
MySQL Oslayer performace optimization
Louis liu
 
PDF
An Overview to MySQL SYS Schema
Mydbops
 
PPTX
MySQL Performance Tips & Best Practices
Isaac Mosquera
 
The MySQL SYS Schema
Mark Leith
 
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
Aurimas Mikalauskas
 
The InnoDB Storage Engine for MySQL
Morgan Tocker
 
MySQL Atchitecture and Concepts
Tuyen Vuong
 
Explain that explain
Fabrizio Parrella
 
Performance Tuning Best Practices
webhostingguy
 
Inside PyMongo - MongoNYC
Mike Dirolf
 
InnoDB Locking Explained with Stick Figures
Karwin Software Solutions LLC
 
InnoDB architecture and performance optimization (Пётр Зайцев)
Ontico
 
How to Analyze and Tune MySQL Queries for Better Performance
oysteing
 
How to analyze and tune sql queries for better performance percona15
oysteing
 
Performance Schema and Sys Schema in MySQL 5.7
Mark Leith
 
Performance Schema in MySQL (Danil Zburivsky)
Ontico
 
MySQL Troubleshooting with the Performance Schema
Sveta Smirnova
 
The MySQL Performance Schema & New SYS Schema
Ted Wennmark
 
MySQL Performance - SydPHP October 2011
Graham Weldon
 
MySQL EXPLAIN Explained-Norvald H. Ryeng
郁萍 王
 
MySQL Oslayer performace optimization
Louis liu
 
An Overview to MySQL SYS Schema
Mydbops
 
MySQL Performance Tips & Best Practices
Isaac Mosquera
 
Ad

Similar to Performance Schema for MySQL troubleshooting (20)

PDF
MySQL's Performance Schema, SYS Schema and Workbench Integration
Mario Beck
 
PDF
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
PDF
Mysql tech day_paris_ps_and_sys
Mark Leith
 
PDF
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
PDF
MySQL Performance Schema in Action
Sveta Smirnova
 
PDF
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
PPTX
MySQL Performance Schema in MySQL 8.0
Mayank Prasad
 
PDF
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
PPTX
Mysql Performance Schema - fossasia 2016
Mayank Prasad
 
PDF
MySQL Performance Schema in Action: the Complete Tutorial
Sveta Smirnova
 
PDF
MySQL Performance Schema in Action
Sveta Smirnova
 
PDF
sveta smirnova - my sql performance schema in action
Dariia Seimova
 
PDF
Performance Schema in Action: demo
Sveta Smirnova
 
ODP
MySQL Monitoring Mechanisms
Mark Leith
 
ODP
MySQL Monitoring Mechanisms
Mark Leith
 
PPTX
MySQL Performance Schema : fossasia
Mayank Prasad
 
PDF
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
PDF
MySQL Performance schema missing_manual_flossuk
Valeriy Kravchuk
 
PDF
Troubleshooting MySQL Performance
Sveta Smirnova
 
PDF
New features in Performance Schema 5.7 in action
Sveta Smirnova
 
MySQL's Performance Schema, SYS Schema and Workbench Integration
Mario Beck
 
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Mysql tech day_paris_ps_and_sys
Mark Leith
 
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
MySQL Performance Schema in Action
Sveta Smirnova
 
MySQL Performance Schema in 20 Minutes
Sveta Smirnova
 
MySQL Performance Schema in MySQL 8.0
Mayank Prasad
 
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
Mysql Performance Schema - fossasia 2016
Mayank Prasad
 
MySQL Performance Schema in Action: the Complete Tutorial
Sveta Smirnova
 
MySQL Performance Schema in Action
Sveta Smirnova
 
sveta smirnova - my sql performance schema in action
Dariia Seimova
 
Performance Schema in Action: demo
Sveta Smirnova
 
MySQL Monitoring Mechanisms
Mark Leith
 
MySQL Monitoring Mechanisms
Mark Leith
 
MySQL Performance Schema : fossasia
Mayank Prasad
 
Performance Schema for MySQL Troubleshooting
Sveta Smirnova
 
MySQL Performance schema missing_manual_flossuk
Valeriy Kravchuk
 
Troubleshooting MySQL Performance
Sveta Smirnova
 
New features in Performance Schema 5.7 in action
Sveta Smirnova
 
Ad

More from Sveta Smirnova (20)

PDF
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
PDF
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
Sveta Smirnova
 
PDF
Database in Kubernetes: Diagnostics and Monitoring
Sveta Smirnova
 
PDF
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
PDF
MySQL Cookbook: Recipes for Developers
Sveta Smirnova
 
PDF
MySQL Performance for DevOps
Sveta Smirnova
 
PDF
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
PDF
MySQL Cookbook: Recipes for Your Business
Sveta Smirnova
 
PDF
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
PDF
Производительность MySQL для DevOps
Sveta Smirnova
 
PDF
MySQL Performance for DevOps
Sveta Smirnova
 
PDF
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
PDF
How to migrate from MySQL to MariaDB without tears
Sveta Smirnova
 
PDF
Modern solutions for modern database load: improvements in the latest MariaDB...
Sveta Smirnova
 
PDF
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
PDF
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 
PDF
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
PDF
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
PDF
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
PDF
Billion Goods in Few Categories: How Histograms Save a Life?
Sveta Smirnova
 
War Story: Removing Offensive Language from Percona Toolkit
Sveta Smirnova
 
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
Sveta Smirnova
 
Database in Kubernetes: Diagnostics and Monitoring
Sveta Smirnova
 
MySQL Database Monitoring: Must, Good and Nice to Have
Sveta Smirnova
 
MySQL Cookbook: Recipes for Developers
Sveta Smirnova
 
MySQL Performance for DevOps
Sveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
Sveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
Sveta Smirnova
 
Introduction into MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
Производительность MySQL для DevOps
Sveta Smirnova
 
MySQL Performance for DevOps
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster
Sveta Smirnova
 
How to migrate from MySQL to MariaDB without tears
Sveta Smirnova
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Sveta Smirnova
 
How to Avoid Pitfalls in Schema Upgrade with Galera
Sveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
Sveta Smirnova
 
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Sveta Smirnova
 

Recently uploaded (20)

PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Digital Circuits, important subject in CS
contactparinay1
 

Performance Schema for MySQL troubleshooting