SlideShare a Scribd company logo
1 of 67
Download to read offline
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL SYS Schema
Deep Dive
Mark Leith
Senior Software Development Manager
MySQL Enterprise Tools, Oracle
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
2
3
4
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
2
3
4
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
You are … :
• Using 5.1?
• Using 5.5?
• Using 5.6?
• Using 5.7?
• A Performance Schema user?
• A Sys Schema user?
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Why the sys schema?
• Performance Schema exposes a huge amount of data
• Many of its tables can implement multiple different use cases,
depending on the type of data
• The sys schema layers on top the (sometimes complex) queries in to
a packaged set of easy to use views
• It also adds a number of functions and procedures that help format,
configure the output of, and record, Performance Schema data
• Implements many of the common day to day DBA and Developer
debugging and tuning use cases
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
2
3
4
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Installation from the command line
• $ git clone https://github.com/MarkLeith/mysql-sys.git /tmp/sys
• $ cd /tmp/sys
• $ mysql -u user -p < sys_<version>.sql
<version> can be 56 or 57, for 5.6 and 5.7 respectively
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Installation from MySQL Workbench 6.1+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Installation on the new MySQL 5.7 GA
• Do nothing other than install/mysql_upgrade it is there by default!
• You will be able to install future upgrades from the sys repository
as you wish, no restrictions there
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
select * from sys.version;
+-------------+---------------+
| sys_version | mysql_version |
+-------------+---------------+
| 1.5.0 | 5.7.9 |
+-------------+---------------+
10
Checking sys is loaded
mysql> select *
-> from sys.schema_object_overview
-> where db = 'sys';
+-----+---------------+-------+
| db | object_type | count |
+-----+---------------+-------+
| sys | BASE TABLE | 1 |
| sys | INDEX (BTREE) | 1 |
| sys | TRIGGER | 2 |
| sys | FUNCTION | 21 |
| sys | PROCEDURE | 26 |
| sys | VIEW | 100 |
+-----+---------------+-------+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
3
2
4
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Make output human readable
• Format time appropriately
• Format bytes appropriately
• Truncate output for large
width values for CLI
• Extract object names
• Check instrumentation state
12
Formatting / Helper Functions
format_time
format_bytes
format_path
format_statement
extract_table_from_file_name
extract_schema_from_file_name
ps_is_account_enabled
ps_is_consumer_enabled
ps_is_instrument_default_enabled
ps_is_instrument_default_timed
ps_is_thread_instrumented
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
format_time() function
mysql> select format_time(23849723429) as time
-> union select format_time(8327423749233)
-> union select format_time(83274237492335);
+-------------+
| time |
+-------------+
| 23.85 ms |
| 8.33 s |
| 00:01:23.27 |
+-------------+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
format_bytes() function
mysql> select format_bytes(23423) as bytes
-> union select format_bytes(23432423)
-> union select format_bytes(42839479283)
-> union select format_bytes(2293848203489);
+-----------+
| bytes |
+-----------+
| 22.87 KiB |
| 22.35 MiB |
| 39.90 GiB |
| 2.09 TiB |
+-----------+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Performance Schema Config Helper Procedures
• ps_setup_show_disabled() / ps_setup_show_enabled()
• ps_setup_disable_thread() / ps_setup_enable_thread()
• ps_setup_disable_background_threads() /
ps_setup_enable_background_threads()
• ps_setup_disable_instrument() / ps_setup_enable_instrument()
• ps_setup_disable_consumer() / ps_setup_enable_consumer()
• ps_setup_save() / ps_setup_reload_saved()
• ps_setup_reset_to_default() / ps_truncate_all_tables()
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
4
2
3
5
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Dump all P_S data to a dot
graph file to trace a thread
• Look in the statement history
table to capture more info on
a statement digest
• Show detailed transaction info
• Dump as much diagnostics info
as possible (support enabler)
17
Statement Tracing Routines
ps_trace_thread
ps_trace_statement_digest
ps_thread_trx_info
ps_thread_stack
ps_statement_avg_latency_histogram
diagnostics
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_statement_digest procedure
• ps_trace_statement_digest() analyses live traffic looking for
certain statement digest for a period of time
• Captures statistics on each matching statement it finds
• Returns a report of the captured stats
• An overall summary
• A break down for the longest running example
• An EXPLAIN (if the statement is not truncated)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_statement_digest procedure
• ps_trace_statement_digest() parameters
• in_digest The statement digest to analyse
• in_runtime How long to run analysis for
• in_interval How often to snapshot data
• in_start_fresh Whether to truncate P_S tables first
• in_auto_enable Whether to auto enable required config
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_statement_digest procedure example
mysql> call ps_trace_statement_digest(‘6134e9d6f25eb8e6cddf11f6938f202a’, 60, 1, true, true);
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
1 row in set (59.93 sec)
+------------+-----------+-----------+-----------+---------------+------------+------------+
| executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
+------------+-----------+-----------+-----------+---------------+------------+------------+
| 360 | 1.41 s | 138.39 ms | 720 | 0 | 0 | 0 |
+------------+-----------+-----------+-----------+---------------+------------+------------+
1 row in set (59.93 sec)
+--------------------------------+-------+-----------+
| event_name | count | latency |
+--------------------------------+-------+-----------+
| stage/sql/Sending data | 14 | 1.10 s |
| stage/sql/update | 198 | 667.34 ms |
| stage/sql/removing tmp table | 9 | 240.48 ms |
...
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_statement_digest procedure example
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
1 row in set (59.95 sec)
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| 23277 | 77.64 ms | 97.00 us | 2 | 0 | 0 | 0 |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
1 row in set (59.95 sec)
+-------------------------------------------------------------------------------------------+
| sql_text |
+-------------------------------------------------------------------------------------------+
| /* mem dbpool.default */ insert into `mem__quan`.`normalized_statements_by_server_by_schema`
(firstSeen, lastSeen, normalized_statement_id, `schema`, server, id) values (1378983745000,
1378998600000, x'808ACEB88FC4B45BC47C4FE9D86C7F26', 'mem', '753c939e-1b99-11e3-b6d4-bc761a1f4f2f',
x'7CFE81F98B1E3FE0895D1AA2C39B326D') ON DUPLICATE KEY UPDATE ...
+-------------------------------------------------------------------------------------------+
...
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_statement_digest procedure example
+--------------------------------+----------+
| event_name | latency |
+--------------------------------+----------+
| stage/sql/init | 10.41 ms |
| stage/sql/checking permissions | 2.35 us |
| stage/sql/Opening tables | 10.32 us |
| stage/sql/init | 13.53 us |
| stage/sql/System lock | 3.66 us |
| stage/sql/update | 61.74 ms |
| stage/sql/end | 1.11 us |
| stage/sql/query end | 1.31 us |
| stage/sql/closing tables | 5.44 ms |
| stage/sql/freeing items | 23.31 us |
+--------------------------------+----------+
10 rows in set (59.99 sec)
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
...
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
sys.ps_thread_trx_info(<thread_id>)
SELECT sys.ps_thread_trx_info(48) as trx_infoG
*************************** 1. row ***************************
trx_info: [
{
"time": "790.70 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (1, 'foo')",
"time": "471.02 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 1,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
},
...
Pass in thread id
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_thread procedure
• ps_trace_thread() monitors a specific thread for a period
• Captures as much information on the thread activity as possible
• Returns a “dot” formatted file, that can graph the event hierarchy
• http://en.wikipedia.org/wiki/DOT_(graph_description_language)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_thread procedure
• ps_trace_thread parameters
• in_thread_id The thread to analyse
• in_outfile The file to dump the data to (INTO OUTFILE)
• in_max_runtime How long to run analysis for
• in_interval How often to snapshot for data
• in_start_fresh Whether to truncate P_S tables first
• in_auto_setup Whether to auto enable required config
• in_debug Whether to also print debug info (source info)
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_thread procedure example
mysql> call ps_trace_thread(27768, '/tmp/stack_27768.dot', 60, 0.1, true, true, true);
+------------------------------------------------+
| Info |
+------------------------------------------------+
| Data collection starting for THREAD_ID = 27768 |
+------------------------------------------------+
1 row in set (4.82 sec)
+---------------------------------------------+
| Info |
+---------------------------------------------+
| Stack trace written to /tmp/stack_27768.dot |
+---------------------------------------------+
1 row in set (60.90 sec)
+--------------------------------------------------------+
| Convert to PDF |
+--------------------------------------------------------+
| dot -Tpdf -o /tmp/stack_27768.pdf /tmp/stack_27768.dot |
+--------------------------------------------------------+
1 row in set (60.90 sec)
+--------------------------------------------------------+
| Convert to PNG |
+--------------------------------------------------------+
| dot -Tpng -o /tmp/stack_27768.png /tmp/stack_27768.dot |
+--------------------------------------------------------+
1 row in set (60.90 sec)+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_thread procedure example
cerberus:~ mark$ more Documents/statement_graphs/deletes.dot
digraph events {
graph [rankdir=LR, nodesep="0.10"];
node [label="N"];
graph [bb="0,0,1860,17476"];
1 [label="(0.20μ) mysys/THR_LOCK_threadsn", style=filled, color=lightskyblue, pos="209,18", width="3.19", height="0.50"];
2 [label="(0.18μ) sql/THD::LOCK_thd_datan", style=filled, color=lightskyblue, pos="209,61", width="3.06", height="0.50"];
3 [label="(0.24μ) sql/hash_filo::lockn", style=filled, color=lightskyblue, pos="209,104", width="2.42", height=“0.50"];
4 [label="(0.31μ) sql/LOGGER::LOCK_logger - read_lockn", style=filled, color=orchid, pos="209,147", width="4.22",
height="0.50"];
5 [label="(0.08μ) sql/LOG::LOCK_logn", style=filled, color=lightskyblue, pos="209,190", width="2.64", height="0.50"];
6 [label="(12.97μ) wait/io/file/sql/query_log - write 49 bytesn/Users/mark/mysql/lp-mysql-trunk/mysql-test/var/mysqld.1/
mysqld.logn", style=filled, color=red, shape=box, pos="209,235", width="5.78", height="0.56"];
7 [label="(176.14μ) sql/selectnselect @@version_comment limit 1nerrors: 0nwarnings: 0nlock time: 0.00μnrows affected:
0nrows sent:
209,18", width="3.19", height="0.50"];mp disk tables: 0nselect scan: 0nselect full join: :
2 [label="(0.18μ) sql/THD::LOCK_thd_datan", style=filled, color=lightskyblue, pos="209,61", width="3.06", height="0.50"];
3 [label="(0.24μ) sql/hash_filo::lockn", style=filled, color=lightskyblue, pos="209,104", width="2.42", height="0.50"];
4 [label="(0.31μ) sql/LOGGER::LOCK_logger - read_lockn", style=filled, color=orchid, pos="209,147", width="4.22",
height="0.50"];
5 [label="(0.08μ) sql/LOG::LOCK_logn", style=filled, color=lightskyblue, pos="209,190", width="2.64", height="0.50"];
……
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
ps_trace_thread procedure example
MySQL 5.7
Procedures
Transactions
Statements
Stages
Waits
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
Introduction to the MySQL sys schema
Installation
Formatting / Helper Routines
Tracing Routines
Summary Views
1
5
2
3
4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL sys views
• Reference set of views solving various administrator use cases
• Simple views, create/copy your own, sys is not “locked down”
• Build upon both performance_schema and INFORMATION_SCHEMA
• Both formatted and raw views are available
• All raw views are prefixed with x$
• Raw views are there for tools to poll
• Formatted views are for humans and the command line
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• High level user/host overviews
• Breakdowns by:
• IO usage
• Stages
• Statement details
• Following show users only
37
User / Host Summary Views
user_summary
user_summary_by_file_io
user_summary_by_file_io_type
user_summary_by_stages
user_summary_by_statement_latency
user_summary_by_statement_type
host_summary
host_summary_by_file_io
host_summary_by_file_io_type
host_summary_by_stages
host_summary_by_statement_latency
host_summary_by_statement_type
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
user_summary view
mysql> select * from user_summaryG
*************************** 1. row ***************************
user: mark
statements: 3072
statement_latency: 1.77 s
statement_avg_latency: 575.29 us
table_scans: 7
file_ios: 20043
file_io_latency: 346.79 ms
current_connections: 1
total_connections: 1
unique_hosts: 1
current_memory: 515.81 KiB
total_memory_allocated: 30.69 MiB
MySQL 5.7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
user_summary_by_file_io_type view
mysql> select * from user_summary_by_file_io_type;
+------+--------------------------------------+---------+-------------+-------------+
| user | event_name | total | latency | max_latency |
+------+--------------------------------------+---------+-------------+-------------+
| mark | wait/io/file/myisam/dfile | 19540 | 215.20 ms | 120.79 ms |
| mark | wait/io/file/myisam/kfile | 501 | 131.58 ms | 57.74 ms |
| mark | wait/io/file/sql/dbopt | 2 | 17.29 us | 9.17 us |
| root | wait/io/file/innodb/innodb_log_file | 2079432 | 00:28:27.62 | 1.30 s |
| root | wait/io/file/myisam/kfile | 5195927 | 00:17:07.33 | 1.17 s |
| root | wait/io/file/myisam/dfile | 1533813 | 00:07:27.59 | 1.18 s |
| root | wait/io/file/sql/binlog | 3517008 | 00:03:07.34 | 1.42 s |
| root | wait/io/file/innodb/innodb_data_file | 20720 | 00:02:37.81 | 492.23 ms |
| root | wait/io/file/sql/FRM | 41412 | 3.17 s | 80.43 ms |
| root | wait/io/file/sql/dbopt | 110993 | 1.23 s | 63.27 ms |
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
user_summary_by_statement_latency view
mysql> select * from user_summary_by_statement_latencyG
*************************** 1. row ***************************
user: mark
total: 176
total_latency: 1.26 s
max_latency: 583.33 ms
lock_latency: 216.95 ms
rows_sent: 311
rows_examined: 307
rows_affected: 0
full_scans: 7
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
user_summary_by_statement_type view
mysql> select * from user_summary_by_statement_typeG
*************************** 1. row ***************************
user: mark
statement: commit
total: 2463190
total_latency: 13.33h
max_latency: 12.18 s
lock_latency: 0 ps
rows_sent: 0
rows_examined: 0
rows_affected: 0
full_scans: 0
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• IO by current threads
• Global summaries by file and
class, aggregating by bytes or
latency
• Stream of last file IO events in
raw form
42
IO Summary Views
io_by_thread_by_latency
io_global_by_file_by_bytes
io_global_by_file_by_latency
io_global_by_wait_by_bytes
io_global_by_wait_by_latency
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
io_by_thread_by_latency view
mysql> select * from io_by_thread_by_latencyG
*************************** 1. row ***************************
user: main
total: 1193
total_latency: 136.45 ms
min_latency: 731.38 ns
avg_latency: 269.99 us
max_latency: 20.72 ms
thread_id: 1
processlist_id: NULL
*************************** 2. row ***************************
user: root@localhost
total: 533
total_latency: 53.81 ms
min_latency: 780.39 ns
avg_latency: 8.41 ms
max_latency: 25.06 ms
thread_id: 23
processlist_id: 4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
io_global_by_file_by_latency view
mysql> select * from io_global_by_file_by_latency limit 1G
*************************** 1. row ***************************
file: @@datadir/ibdata1
total: 1395714
total_latency: 00:28:53.06
count_read: 1006
read_latency: 4.51 s
count_write: 1326529
write_latency: 33.39 s
count_misc: 68179
misc_latency: 00:28:15.16
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
latest_file_io view
mysql> select * from latest_file_io;
+-----------------------------+----------------------------------+-----------+-----------+-----------+
| thread | file | latency | operation | requested |
+-----------------------------+----------------------------------+-----------+-----------+-----------+
| root@localhost:63153:179371 | @@datadir/ib_logfile1 | 7.16 us | lock | NULL |
| root@localhost:63153:179371 | @@datadir/ib_logfile1 | 6.16 us | write | 1.50 KiB |
| root@localhost:63153:179371 | @@datadir/ib_logfile1 | 14.36 ms | sync | NULL |
| root@localhost:63153:179371 | @@datadir/cerberus-bin.000012 | 28.25 us | write | 905 bytes |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 15.25 us | write | 1.00 KiB |
| root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 32.12 us | read | 905 bytes |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 6.65 us | write | 1.00 KiB |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 213.32 us | sync | NULL |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 17.27 us | write | 1.00 KiB |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 286.01 us | sync | NULL |
| root@localhost:63177:179394 | @@datadir/cerberus-bin.000012 | 18.77 us | write | 601 bytes |
| root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 7.55 us | read | 601 bytes |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 10.67 us | write | 1.00 KiB |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 200.28 us | sync | NULL |
| root@localhost:63177:179394 | @@datadir/cerberus-bin.000012 | 12.91 us | write | 601 bytes |
| root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 6.47 us | read | 601 bytes |
| root@localhost:63177:179394 | @@datadir/ib_logfile1 | 9.22 us | write | 1.50 KiB |
……
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Object overview
• Table usage statistics
• Index usage statistics
• Following show users only
46
Schema Analysis Views
schema_index_statistics
schema_object_overview
schema_table_statistics
schema_table_statistics_with_buffer
schema_tables_with_full_table_scans
schema_unused_indexes
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
schema_table_statistics view
mysql> select * from schema_table_statistics limit 1G
*************************** 1. row ***************************
table_schema: mem__quan
table_name: normalized_statements_by_server_by_schema_data
total_latency: 00:55:07.80
rows_fetched: 239685
fetch_latency: 17.10 s
rows_inserted: 1102895
insert_latency: 00:52:18.10
rows_updated: 55910
update_latency: 00:02:28.62
rows_deleted: 17899
delete_latency: 3.98 s
io_read_requests: 20639
io_read: 324.94 MiB
io_read_latency: 00:03:04.10
io_write_requests: 1965973
io_write: 40.36 GiB
io_write_latency: 25.46 s
io_misc_requests: 18217
io_misc_latency: 00:14:06.02
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
schema_index_statistics view
mysql> select * from schema_index_statistics limit 1G
*************************** 1. row ***************************
table_schema: mem__inventory
table_name: mysqlconnectionconfiguration
index_name: PRIMARY
rows_selected: 131399
select_latency: 00:07:05.03
rows_inserted: 0
insert_latency: 0 ps
rows_updated: 41608
update_latency: 21.96 s
rows_deleted: 0
delete_latency: 0 ps
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
schema_tables_with_full_table_scans view
mysql> select * from schema_tables_with_full_table_scans limit 10;
+--------------------+--------------------------------+-------------------+-----------+
| object_schema | object_name | rows_full_scanned | latency |
+--------------------+--------------------------------+-------------------+-----------+
| mem30__instruments | fsstatistics | 10207042 | 13.10 s |
| mem30__instruments | preparedstatementapidata | 436428 | 973.27 ms |
| mem30__instruments | mysqlprocessactivity | 411702 | 282.07 ms |
| mem30__instruments | querycachequeriesincachedata | 374011 | 767.15 ms |
| mem30__instruments | rowaccessesdata | 322321 | 1.55 s |
| mem30__instruments | connectionsmaxdata | 301242 | 857.63 ms |
| mem30__instruments | innodbdatadictionarymemorydata | 292564 | 495.38 ms |
| mem30__instruments | innodbbufferpooldata | 277112 | 1.95 s |
| mem30__instruments | avgrowaccessesdata | 269236 | 1.25 s |
| mem30__instruments | innodbrowdetailsdata | 248208 | 653.25 ms |
+--------------------+--------------------------------+-------------------+-----------+
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
schema_unused_indexes view
mysql> select * from schema_unused_indexes limit 10;
+--------------------+-----------------------------------+--------------------+
| object_schema | object_name | index_name |
+--------------------+-----------------------------------+--------------------+
| mem30__bean_config | plists | path |
| mem30__config | group_selections | name |
| mem30__config | notification_groups | name |
| mem30__config | user_form_defaults | FKC1AEF1F9E7EE2CFB |
| mem30__enterprise | whats_new_entries | entryId |
| mem30__events | action_logs | policyId |
| mem30__events | action_logs | eventId |
| mem30__events | action_logs | ts |
| mem30__events | advisor_scopes_advisorcategoryids | FKF0CB0DB962CAB4 |
| mem30__events | advisor_scopes_advisorclassids | FK650AF1BF962CAB4 |
+--------------------+-----------------------------------+--------------------+
You should ensure you have representative time frame before taking any actions!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Wait summaries by class
• Wait details per:
• User
• Host
• Globally
51
Wait Analysis Views
wait_classes_global_by_avg_latency
wait_classes_global_by_latency
waits_by_host_by_latency
waits_by_user_by_latency
waits_global_by_latency
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
waits_global_by_latency view
mysql> select * from waits_global_by_latency limit 10;
+--------------------------------------+----------+---------------+-------------+-------------+
| events | total | total_latency | avg_latency | max_latency |
+--------------------------------------+----------+---------------+-------------+-------------+
| wait/io/table/sql/handler | 24196659 | 1.75h | 259.72 us | 2.29 s |
| wait/io/file/innodb/innodb_data_file | 5964255 | 1.36h | 822.01 us | 1.49 s |
| wait/io/file/innodb/innodb_log_file | 2272647 | 00:36:41.37 | 968.64 us | 1.30 s |
| wait/io/file/myisam/kfile | 5463587 | 00:18:14.16 | 200.26 us | 1.17 s |
| wait/io/file/myisam/dfile | 1715187 | 00:08:00.18 | 279.96 us | 1.18 s |
| wait/io/file/sql/binlog | 3722079 | 00:03:23.71 | 54.73 us | 1.42 s |
| wait/lock/table/sql/handler | 10074274 | 00:01:56.63 | 11.58 us | 186.90 ms |
| wait/io/socket/sql/client_connection | 3879827 | 25.36 s | 6.54 us | 219.25 ms |
| wait/io/file/sql/FRM | 43994 | 3.27 s | 74.35 us | 80.43 ms |
| wait/io/file/sql/dbopt | 116765 | 1.29 s | 11.03 us | 63.27 ms |
+--------------------------------------+----------+---------------+-------------+-------------+
InnoDB only instance, this MyISAM IO is all temporary tables, focus tuning there!
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
waits_by_user_by_latency view
mysql> select * from waits_by_user_by_latency;
+------+--------------------------------------+----------+---------------+-------------+-------------+
| user | event | total | total_latency | avg_latency | max_latency |
+------+--------------------------------------+----------+---------------+-------------+-------------+
| mark | wait/io/file/myisam/dfile | 19540 | 215.20 ms | 11.01 us | 120.79 ms |
| mark | wait/io/file/myisam/kfile | 501 | 131.58 ms | 262.63 us | 57.74 ms |
| mark | wait/io/file/sql/dbopt | 2 | 17.29 us | 8.64 us | 9.17 us |
| root | wait/io/table/sql/handler | 24189319 | 1.74h | 258.77 us | 2.29 s |
| root | wait/io/file/innodb/innodb_log_file | 2162650 | 00:30:52.87 | 856.76 us | 1.30 s |
| root | wait/io/file/myisam/kfile | 5460992 | 00:18:12.83 | 200.11 us | 1.17 s |
| root | wait/io/file/myisam/dfile | 1694624 | 00:07:59.50 | 282.95 us | 1.18 s |
| root | wait/io/file/sql/binlog | 3711637 | 00:03:23.16 | 54.74 us | 1.42 s |
| root | wait/io/file/innodb/innodb_data_file | 22577 | 00:03:05.73 | 8.23 ms | 492.23 ms |
| root | wait/lock/table/sql/handler | 10069000 | 00:01:56.59 | 11.58 us | 186.90 ms |
……
root is doing the most temporary table IO
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Table Metadata Lock Waits
• InnoDB Row Lock Waits
54
Lock Wait Views
schema_table_lock_waits
innodb_lock_waits
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
sys.schema_table_lock_waits
mysql> select * from sys.schema_table_lock_waitsG
*************************** 1. row ***************************
object_schema: test
object_name: t
waiting_thread_id: 43
waiting_pid: 21
waiting_account: msandbox@localhost
waiting_lock_type: SHARED_UPGRADABLE
waiting_lock_duration: TRANSACTION
waiting_query: alter table test.t add foo int
waiting_query_secs: 988
waiting_query_rows_affected: 0
waiting_query_rows_examined: 0
blocking_thread_id: 42
blocking_pid: 20
blocking_account: msandbox@localhost
blocking_lock_type: SHARED_NO_READ_WRITE
blocking_lock_duration: TRANSACTION
sql_kill_blocking_query: KILL QUERY 20
sql_kill_blocking_connection: KILL 20
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
sys.innodb_lock_waits
mysql> SELECT * FROM sys.innodb_lock_waitsG
*************************** 1. row ***************************
wait_started: 2014-11-11 13:39:20
wait_age: 00:00:07
wait_age_secs: 7
locked_table: `db1`.`t1`
locked_index: PRIMARY
locked_type: RECORD
waiting_trx_id: 867158
waiting_trx_started: 2014-11-11 13:39:15
waiting_trx_age: 00:00:12
waiting_trx_rows_locked: 0
waiting_trx_rows_modified: 0
waiting_pid: 3
waiting_query: UPDATE t1 SET val = val + 1 WHERE id = 2
waiting_lock_id: 867158:2363:3:3
waiting_lock_mode: X
blocking_trx_id: 867157
blocking_pid: 4
...
blocking_query: UPDATE t1 SET val …
blocking_lock_id: 867157:2363:3:3
blocking_lock_mode: X
blocking_trx_started: 2014-11-11 13:39:11
blocking_trx_age: 00:00:16
blocking_trx_rows_locked: 1
blocking_trx_rows_modified: 1
sql_kill_blocking_query: KILL QUERY 4
sql_kill_blocking_connection: KILL 4
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Statement overview
• Find statements by:
• Those with errors
• Those with full table scans
• Those creating temp tables
• Those that cause sorting
• With latency in 95th %ile
57
Statement Analysis Views
statement_analysis
statements_with_errors_or_warnings
statements_with_full_table_scans
statements_with_runtimes_in_95th_p
ercentile
statements_with_sorting
statements_with_temp_tables
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
statement_analysis view
mysql> select * from statement_analysis limit 2G
*************************** 1. row ***************************
query: INSERT INTO `mem30__quan` . `n ... nDuration` = IF ( VALUES ( ...
db: mem
full_scan:
exec_count: 4657
err_count: 0
warn_count: 0
total_latency: 00:03:57.40
max_latency: 10.54 s
avg_latency: 50.98 ms
lock_latency: 00:03:00.93
rows_sent: 0
rows_sent_avg: 0
rows_examined: 0
rows_examined_avg: 0
rows_affected: 4794
rows_affected_avg: 1
tmp_tables: 0
tmp_disk_tables: 0
rows_sorted: 0
sort_merge_passes: 0
digest: b98bfe333642e8e4e72c73515810d865
first_seen: 2014-09-24 11:27:01
last_seen: 2014-09-24 11:53:00
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
statements_with_errors_or_warnings view
mysql> select * from statements_with_errors_or_warnings limit 1G
*************************** 1. row ***************************
query: CREATE TEMPORARY TABLE IF NOT ... _logs` ( `id` INT8 NOT NULL )
db: mem
exec_count: 1725
errors: 1725
error_pct: 100.0000
warnings: 0
warning_pct: 0.0000
first_seen: 2014-05-20 10:42:32
last_seen: 2014-05-21 18:39:22
digest: 51fb979dbc3910a6294c7cdabd7839c3
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
statements_with_temp_tables view
mysql> select * from statements_with_temp_tables limit 1G
*************************** 1. row ***************************
query: SELECT * FROM ( SELECT `digest ... ` ,
`sum_no_index_used` AS ...
db: mysql
exec_count: 68
total_latency: 2.31 s
memory_tmp_tables: 476
disk_tmp_tables: 204
avg_tmp_tables_per_query: 7
tmp_tables_to_disk_pct: 43
first_seen: 2014-09-24 11:26:18
last_seen: 2014-09-24 12:33:00
digest: 50761c6a1818824328745d8a136b9ed6
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
statements_with_full_table_scans view
mysql> select * from statements_with_full_table_scans limit 1G
*************************** 1. row ***************************
query: SELECT `pojotimese0_` . `id` A ...
ty_timeseries` `pojotimese0_`
db: mem
exec_count: 1
total_latency: 940.89 us
no_index_used_count: 1
no_good_index_used_count: 0
no_index_used_pct: 100
rows_sent: 116
rows_examined: 116
rows_sent_avg: 116
rows_examined_avg: 116
first_seen: 2014-09-24 11:25:03
last_seen: 2014-09-24 11:25:03
digest: f81b5ce10baee9be754cf35fd245a516
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
• Better SHOW PROCESSLIST
• No mutex contention
• Live statistics for query
• Consolidated metrics
62
Miscellaneous Views
processlist
session
metrics
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
processlist / session views
mysql> select * from sessionG
*************************** 1. row ***************************
thd_id: 7890
conn_id: 7870
user: root@localhost
db: mem
command: Query
state: update
time: 0
current_statement: /* mem dbpool.default */ inser ...<truncated>
lock_latency: 0 ps
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
full_scan: NO
last_statement: NULL
last_statement_latency: NULL
last_wait: wait/io/table/sql/handler
last_wait_latency: Still Waiting
source: handler.cc:7274
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
sys.sessions progress estimation
mysql> select * from sys.sessionsG
*************************** 1. row ***************************
thd_id: 44524
conn_id: 44502
user: msandbox@localhost
db: test
command: Query
state: alter table (flush)
time: 18
current_statement: alter table t1 add column g int
statement_latency: 18.45 s
progress: 98.84
lock_latency: 265.43 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 0
tmp_disk_tables: 0
...
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
sys.metrics
mysql> select * from sys.metrics limit 199, 10;
+-----------------------------+----------------+--------------------------------------+---------+
| Variable_name | Variable_value | Type | Enabled |
+-----------------------------+----------------+--------------------------------------+---------+
| tc_log_page_waits | 0 | Global Status | YES |
| threads_cached | 7 | Global Status | YES |
| threads_connected | 3 | Global Status | YES |
| threads_created | 10 | Global Status | YES |
| threads_running | 3 | Global Status | YES |
| uptime | 275689 | Global Status | YES |
| uptime_since_flush_status | 275689 | Global Status | YES |
| adaptive_hash_pages_added | 0 | InnoDB Metrics - adaptive_hash_index | NO |
| adaptive_hash_pages_removed | 0 | InnoDB Metrics - adaptive_hash_index | NO |
| adaptive_hash_rows_added | 0 | InnoDB Metrics - adaptive_hash_index | NO |
+-----------------------------+----------------+--------------------------------------+---------+
performance_schema.global_status
information_schema.innodb_metrics
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
MySQL sys schema deep dive

More Related Content

What's hot

Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Mark Leith
 
Introduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise MonitorIntroduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise MonitorMark Leith
 
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 Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and MonitoringMark Leith
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsMark Leith
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaMark Leith
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise MonitorMario Beck
 
Basic MySQL Troubleshooting for Oracle DBAs
Basic MySQL Troubleshooting for Oracle DBAsBasic MySQL Troubleshooting for Oracle DBAs
Basic MySQL Troubleshooting for Oracle DBAsSveta Smirnova
 
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
 
Tx lf propercareandfeedmysql
Tx lf propercareandfeedmysqlTx lf propercareandfeedmysql
Tx lf propercareandfeedmysqlDave Stokes
 
Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema PluginsMark Leith
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMark Leith
 
Oracle Failover Database Cluster with Grid Infrastructure 12c
Oracle Failover Database Cluster with Grid Infrastructure 12cOracle Failover Database Cluster with Grid Infrastructure 12c
Oracle Failover Database Cluster with Grid Infrastructure 12cTrivadis
 
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014Dave Stokes
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance TuningMark Swarbrick
 
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 5.6 Updates
MySQL 5.6 UpdatesMySQL 5.6 Updates
MySQL 5.6 UpdatesDave Stokes
 
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorSolving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorOracleMySQL
 

What's hot (20)

Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7Performance Schema and Sys Schema in MySQL 5.7
Performance Schema and Sys Schema in MySQL 5.7
 
Introduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise MonitorIntroduction to MySQL Enterprise Monitor
Introduction to MySQL Enterprise Monitor
 
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 Administration and Monitoring
MySQL Administration and MonitoringMySQL Administration and Monitoring
MySQL Administration and Monitoring
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Instrumenting plugins for Performance Schema
Instrumenting plugins for Performance SchemaInstrumenting plugins for Performance Schema
Instrumenting plugins for Performance Schema
 
MySQL Enterprise Monitor
MySQL Enterprise MonitorMySQL Enterprise Monitor
MySQL Enterprise Monitor
 
Basic MySQL Troubleshooting for Oracle DBAs
Basic MySQL Troubleshooting for Oracle DBAsBasic MySQL Troubleshooting for Oracle DBAs
Basic MySQL Troubleshooting for Oracle DBAs
 
My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3My sql 5.6&MySQL Cluster 7.3
My sql 5.6&MySQL Cluster 7.3
 
MySQL Monitoring 101
MySQL Monitoring 101MySQL Monitoring 101
MySQL Monitoring 101
 
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
 
Tx lf propercareandfeedmysql
Tx lf propercareandfeedmysqlTx lf propercareandfeedmysql
Tx lf propercareandfeedmysql
 
Developing Information Schema Plugins
Developing Information Schema PluginsDeveloping Information Schema Plugins
Developing Information Schema Plugins
 
MySQL Monitoring Mechanisms
MySQL Monitoring MechanismsMySQL Monitoring Mechanisms
MySQL Monitoring Mechanisms
 
Oracle Failover Database Cluster with Grid Infrastructure 12c
Oracle Failover Database Cluster with Grid Infrastructure 12cOracle Failover Database Cluster with Grid Infrastructure 12c
Oracle Failover Database Cluster with Grid Infrastructure 12c
 
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
 
MySQL Manchester TT - Performance Tuning
MySQL Manchester TT  - Performance TuningMySQL Manchester TT  - Performance Tuning
MySQL Manchester TT - Performance Tuning
 
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 5.6 Updates
MySQL 5.6 UpdatesMySQL 5.6 Updates
MySQL 5.6 Updates
 
Solving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise MonitorSolving Performance Problems Using MySQL Enterprise Monitor
Solving Performance Problems Using MySQL Enterprise Monitor
 

Viewers also liked

Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorMark Leith
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Bernardo Damele A. G.
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMark Leith
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinaroysteing
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performanceoysteing
 

Viewers also liked (6)

Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
MySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema ImprovementsMySQL 5.7: Performance Schema Improvements
MySQL 5.7: Performance Schema Improvements
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
How to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinarHow to analyze and tune sql queries for better performance webinar
How to analyze and tune sql queries for better performance webinar
 
Using Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query PerformanceUsing Optimizer Hints to Improve MySQL Query Performance
Using Optimizer Hints to Improve MySQL Query Performance
 

Similar to MySQL sys schema deep dive

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
 
MySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMark Swarbrick
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxNeoClova
 
제3회난공불락 오픈소스 인프라세미나 - MySQL
제3회난공불락 오픈소스 인프라세미나 - MySQL제3회난공불락 오픈소스 인프라세미나 - MySQL
제3회난공불락 오픈소스 인프라세미나 - MySQLTommy Lee
 
DB Floripa - ProxySQL para MySQL
DB Floripa - ProxySQL para MySQLDB Floripa - ProxySQL para MySQL
DB Floripa - ProxySQL para MySQLMarcelo Altmann
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 MinutesSveta Smirnova
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
MySQL 8.0 Released Update
MySQL 8.0 Released UpdateMySQL 8.0 Released Update
MySQL 8.0 Released UpdateKeith Hollman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012Roland Bouman
 
6 Tips to MySQL Performance Tuning
6 Tips to MySQL Performance Tuning6 Tips to MySQL Performance Tuning
6 Tips to MySQL Performance TuningOracleMySQL
 
Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07Ivan Ma
 
2_MySQL_Cluster_Introduction.pdf
2_MySQL_Cluster_Introduction.pdf2_MySQL_Cluster_Introduction.pdf
2_MySQL_Cluster_Introduction.pdfHaiping Li
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
 

Similar to MySQL sys schema deep dive (20)

Curso de MySQL 5.7
Curso de MySQL 5.7Curso de MySQL 5.7
Curso de MySQL 5.7
 
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
 
MySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & TuneMySQL Tech Tour 2015 - Manage & Tune
MySQL Tech Tour 2015 - Manage & Tune
 
Rootconf admin101
Rootconf admin101Rootconf admin101
Rootconf admin101
 
Perf Tuning Short
Perf Tuning ShortPerf Tuning Short
Perf Tuning Short
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
 
제3회난공불락 오픈소스 인프라세미나 - MySQL
제3회난공불락 오픈소스 인프라세미나 - MySQL제3회난공불락 오픈소스 인프라세미나 - MySQL
제3회난공불락 오픈소스 인프라세미나 - MySQL
 
DB Floripa - ProxySQL para MySQL
DB Floripa - ProxySQL para MySQLDB Floripa - ProxySQL para MySQL
DB Floripa - ProxySQL para MySQL
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 
Guob - MySQL e LGPD
Guob - MySQL e LGPDGuob - MySQL e LGPD
Guob - MySQL e LGPD
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
MySQL 8.0 Released Update
MySQL 8.0 Released UpdateMySQL 8.0 Released Update
MySQL 8.0 Released Update
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Mysql tracing
Mysql tracingMysql tracing
Mysql tracing
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
Common schema my sql uc 2012
Common schema   my sql uc 2012Common schema   my sql uc 2012
Common schema my sql uc 2012
 
6 Tips to MySQL Performance Tuning
6 Tips to MySQL Performance Tuning6 Tips to MySQL Performance Tuning
6 Tips to MySQL Performance Tuning
 
Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07Hkosc group replication-lecture_lab07
Hkosc group replication-lecture_lab07
 
2_MySQL_Cluster_Introduction.pdf
2_MySQL_Cluster_Introduction.pdf2_MySQL_Cluster_Introduction.pdf
2_MySQL_Cluster_Introduction.pdf
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 

Recently uploaded

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 

Recently uploaded (20)

2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 

MySQL sys schema deep dive

  • 1. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL SYS Schema Deep Dive Mark Leith Senior Software Development Manager MySQL Enterprise Tools, Oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 2 3 4 5
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 2 3 4 5
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | You are … : • Using 5.1? • Using 5.5? • Using 5.6? • Using 5.7? • A Performance Schema user? • A Sys Schema user?
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Why the sys schema? • Performance Schema exposes a huge amount of data • Many of its tables can implement multiple different use cases, depending on the type of data • The sys schema layers on top the (sometimes complex) queries in to a packaged set of easy to use views • It also adds a number of functions and procedures that help format, configure the output of, and record, Performance Schema data • Implements many of the common day to day DBA and Developer debugging and tuning use cases
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 2 3 4 5
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Installation from the command line • $ git clone https://github.com/MarkLeith/mysql-sys.git /tmp/sys • $ cd /tmp/sys • $ mysql -u user -p < sys_<version>.sql <version> can be 56 or 57, for 5.6 and 5.7 respectively
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Installation from MySQL Workbench 6.1+
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Installation on the new MySQL 5.7 GA • Do nothing other than install/mysql_upgrade it is there by default! • You will be able to install future upgrades from the sys repository as you wish, no restrictions there
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | select * from sys.version; +-------------+---------------+ | sys_version | mysql_version | +-------------+---------------+ | 1.5.0 | 5.7.9 | +-------------+---------------+ 10 Checking sys is loaded mysql> select * -> from sys.schema_object_overview -> where db = 'sys'; +-----+---------------+-------+ | db | object_type | count | +-----+---------------+-------+ | sys | BASE TABLE | 1 | | sys | INDEX (BTREE) | 1 | | sys | TRIGGER | 2 | | sys | FUNCTION | 21 | | sys | PROCEDURE | 26 | | sys | VIEW | 100 | +-----+---------------+-------+
  • 11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 3 2 4 5
  • 12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Make output human readable • Format time appropriately • Format bytes appropriately • Truncate output for large width values for CLI • Extract object names • Check instrumentation state 12 Formatting / Helper Functions format_time format_bytes format_path format_statement extract_table_from_file_name extract_schema_from_file_name ps_is_account_enabled ps_is_consumer_enabled ps_is_instrument_default_enabled ps_is_instrument_default_timed ps_is_thread_instrumented
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | format_time() function mysql> select format_time(23849723429) as time -> union select format_time(8327423749233) -> union select format_time(83274237492335); +-------------+ | time | +-------------+ | 23.85 ms | | 8.33 s | | 00:01:23.27 | +-------------+
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | format_bytes() function mysql> select format_bytes(23423) as bytes -> union select format_bytes(23432423) -> union select format_bytes(42839479283) -> union select format_bytes(2293848203489); +-----------+ | bytes | +-----------+ | 22.87 KiB | | 22.35 MiB | | 39.90 GiB | | 2.09 TiB | +-----------+
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Performance Schema Config Helper Procedures • ps_setup_show_disabled() / ps_setup_show_enabled() • ps_setup_disable_thread() / ps_setup_enable_thread() • ps_setup_disable_background_threads() / ps_setup_enable_background_threads() • ps_setup_disable_instrument() / ps_setup_enable_instrument() • ps_setup_disable_consumer() / ps_setup_enable_consumer() • ps_setup_save() / ps_setup_reload_saved() • ps_setup_reset_to_default() / ps_truncate_all_tables()
  • 16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 4 2 3 5
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Dump all P_S data to a dot graph file to trace a thread • Look in the statement history table to capture more info on a statement digest • Show detailed transaction info • Dump as much diagnostics info as possible (support enabler) 17 Statement Tracing Routines ps_trace_thread ps_trace_statement_digest ps_thread_trx_info ps_thread_stack ps_statement_avg_latency_histogram diagnostics
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_statement_digest procedure • ps_trace_statement_digest() analyses live traffic looking for certain statement digest for a period of time • Captures statistics on each matching statement it finds • Returns a report of the captured stats • An overall summary • A break down for the longest running example • An EXPLAIN (if the statement is not truncated)
  • 19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_statement_digest procedure • ps_trace_statement_digest() parameters • in_digest The statement digest to analyse • in_runtime How long to run analysis for • in_interval How often to snapshot data • in_start_fresh Whether to truncate P_S tables first • in_auto_enable Whether to auto enable required config
  • 20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_statement_digest procedure example mysql> call ps_trace_statement_digest(‘6134e9d6f25eb8e6cddf11f6938f202a’, 60, 1, true, true); +--------------------+ | SUMMARY STATISTICS | +--------------------+ | SUMMARY STATISTICS | +--------------------+ 1 row in set (59.93 sec) +------------+-----------+-----------+-----------+---------------+------------+------------+ | executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans | +------------+-----------+-----------+-----------+---------------+------------+------------+ | 360 | 1.41 s | 138.39 ms | 720 | 0 | 0 | 0 | +------------+-----------+-----------+-----------+---------------+------------+------------+ 1 row in set (59.93 sec) +--------------------------------+-------+-----------+ | event_name | count | latency | +--------------------------------+-------+-----------+ | stage/sql/Sending data | 14 | 1.10 s | | stage/sql/update | 198 | 667.34 ms | | stage/sql/removing tmp table | 9 | 240.48 ms | ...
  • 21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_statement_digest procedure example +---------------------------+ | LONGEST RUNNING STATEMENT | +---------------------------+ | LONGEST RUNNING STATEMENT | +---------------------------+ 1 row in set (59.95 sec) +-----------+-----------+-----------+-----------+---------------+------------+-----------+ | thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan | +-----------+-----------+-----------+-----------+---------------+------------+-----------+ | 23277 | 77.64 ms | 97.00 us | 2 | 0 | 0 | 0 | +-----------+-----------+-----------+-----------+---------------+------------+-----------+ 1 row in set (59.95 sec) +-------------------------------------------------------------------------------------------+ | sql_text | +-------------------------------------------------------------------------------------------+ | /* mem dbpool.default */ insert into `mem__quan`.`normalized_statements_by_server_by_schema` (firstSeen, lastSeen, normalized_statement_id, `schema`, server, id) values (1378983745000, 1378998600000, x'808ACEB88FC4B45BC47C4FE9D86C7F26', 'mem', '753c939e-1b99-11e3-b6d4-bc761a1f4f2f', x'7CFE81F98B1E3FE0895D1AA2C39B326D') ON DUPLICATE KEY UPDATE ... +-------------------------------------------------------------------------------------------+ ...
  • 22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_statement_digest procedure example +--------------------------------+----------+ | event_name | latency | +--------------------------------+----------+ | stage/sql/init | 10.41 ms | | stage/sql/checking permissions | 2.35 us | | stage/sql/Opening tables | 10.32 us | | stage/sql/init | 13.53 us | | stage/sql/System lock | 3.66 us | | stage/sql/update | 61.74 ms | | stage/sql/end | 1.11 us | | stage/sql/query end | 1.31 us | | stage/sql/closing tables | 5.44 ms | | stage/sql/freeing items | 23.31 us | +--------------------------------+----------+ 10 rows in set (59.99 sec) +----+-------------+-------+------+---------------+------+---------+------+------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+------+---------+------+------+----------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | +----+-------------+-------+------+---------------+------+---------+------+------+----------------+ ...
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | sys.ps_thread_trx_info(<thread_id>) SELECT sys.ps_thread_trx_info(48) as trx_infoG *************************** 1. row *************************** trx_info: [ { "time": "790.70 us", "state": "COMMITTED", "mode": "READ WRITE", "autocommitted": "NO", "gtid": "AUTOMATIC", "isolation": "REPEATABLE READ", "statements_executed": [ { "sql_text": "INSERT INTO info VALUES (1, 'foo')", "time": "471.02 us", "schema": "trx", "rows_examined": 0, "rows_affected": 1, "rows_sent": 0, "tmp_tables": 0, "tmp_disk_tables": 0, "sort_rows": 0, "sort_merge_passes": 0 }, ... Pass in thread id
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_thread procedure • ps_trace_thread() monitors a specific thread for a period • Captures as much information on the thread activity as possible • Returns a “dot” formatted file, that can graph the event hierarchy • http://en.wikipedia.org/wiki/DOT_(graph_description_language)
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_thread procedure • ps_trace_thread parameters • in_thread_id The thread to analyse • in_outfile The file to dump the data to (INTO OUTFILE) • in_max_runtime How long to run analysis for • in_interval How often to snapshot for data • in_start_fresh Whether to truncate P_S tables first • in_auto_setup Whether to auto enable required config • in_debug Whether to also print debug info (source info)
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_thread procedure example mysql> call ps_trace_thread(27768, '/tmp/stack_27768.dot', 60, 0.1, true, true, true); +------------------------------------------------+ | Info | +------------------------------------------------+ | Data collection starting for THREAD_ID = 27768 | +------------------------------------------------+ 1 row in set (4.82 sec) +---------------------------------------------+ | Info | +---------------------------------------------+ | Stack trace written to /tmp/stack_27768.dot | +---------------------------------------------+ 1 row in set (60.90 sec) +--------------------------------------------------------+ | Convert to PDF | +--------------------------------------------------------+ | dot -Tpdf -o /tmp/stack_27768.pdf /tmp/stack_27768.dot | +--------------------------------------------------------+ 1 row in set (60.90 sec) +--------------------------------------------------------+ | Convert to PNG | +--------------------------------------------------------+ | dot -Tpng -o /tmp/stack_27768.png /tmp/stack_27768.dot | +--------------------------------------------------------+ 1 row in set (60.90 sec)+
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_thread procedure example cerberus:~ mark$ more Documents/statement_graphs/deletes.dot digraph events { graph [rankdir=LR, nodesep="0.10"]; node [label="N"]; graph [bb="0,0,1860,17476"]; 1 [label="(0.20μ) mysys/THR_LOCK_threadsn", style=filled, color=lightskyblue, pos="209,18", width="3.19", height="0.50"]; 2 [label="(0.18μ) sql/THD::LOCK_thd_datan", style=filled, color=lightskyblue, pos="209,61", width="3.06", height="0.50"]; 3 [label="(0.24μ) sql/hash_filo::lockn", style=filled, color=lightskyblue, pos="209,104", width="2.42", height=“0.50"]; 4 [label="(0.31μ) sql/LOGGER::LOCK_logger - read_lockn", style=filled, color=orchid, pos="209,147", width="4.22", height="0.50"]; 5 [label="(0.08μ) sql/LOG::LOCK_logn", style=filled, color=lightskyblue, pos="209,190", width="2.64", height="0.50"]; 6 [label="(12.97μ) wait/io/file/sql/query_log - write 49 bytesn/Users/mark/mysql/lp-mysql-trunk/mysql-test/var/mysqld.1/ mysqld.logn", style=filled, color=red, shape=box, pos="209,235", width="5.78", height="0.56"]; 7 [label="(176.14μ) sql/selectnselect @@version_comment limit 1nerrors: 0nwarnings: 0nlock time: 0.00μnrows affected: 0nrows sent: 209,18", width="3.19", height="0.50"];mp disk tables: 0nselect scan: 0nselect full join: : 2 [label="(0.18μ) sql/THD::LOCK_thd_datan", style=filled, color=lightskyblue, pos="209,61", width="3.06", height="0.50"]; 3 [label="(0.24μ) sql/hash_filo::lockn", style=filled, color=lightskyblue, pos="209,104", width="2.42", height="0.50"]; 4 [label="(0.31μ) sql/LOGGER::LOCK_logger - read_lockn", style=filled, color=orchid, pos="209,147", width="4.22", height="0.50"]; 5 [label="(0.08μ) sql/LOG::LOCK_logn", style=filled, color=lightskyblue, pos="209,190", width="2.64", height="0.50"]; ……
  • 28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | ps_trace_thread procedure example MySQL 5.7 Procedures Transactions Statements Stages Waits
  • 29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |
  • 35. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Program Agenda Introduction to the MySQL sys schema Installation Formatting / Helper Routines Tracing Routines Summary Views 1 5 2 3 4
  • 36. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | MySQL sys views • Reference set of views solving various administrator use cases • Simple views, create/copy your own, sys is not “locked down” • Build upon both performance_schema and INFORMATION_SCHEMA • Both formatted and raw views are available • All raw views are prefixed with x$ • Raw views are there for tools to poll • Formatted views are for humans and the command line
  • 37. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • High level user/host overviews • Breakdowns by: • IO usage • Stages • Statement details • Following show users only 37 User / Host Summary Views user_summary user_summary_by_file_io user_summary_by_file_io_type user_summary_by_stages user_summary_by_statement_latency user_summary_by_statement_type host_summary host_summary_by_file_io host_summary_by_file_io_type host_summary_by_stages host_summary_by_statement_latency host_summary_by_statement_type
  • 38. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | user_summary view mysql> select * from user_summaryG *************************** 1. row *************************** user: mark statements: 3072 statement_latency: 1.77 s statement_avg_latency: 575.29 us table_scans: 7 file_ios: 20043 file_io_latency: 346.79 ms current_connections: 1 total_connections: 1 unique_hosts: 1 current_memory: 515.81 KiB total_memory_allocated: 30.69 MiB MySQL 5.7
  • 39. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | user_summary_by_file_io_type view mysql> select * from user_summary_by_file_io_type; +------+--------------------------------------+---------+-------------+-------------+ | user | event_name | total | latency | max_latency | +------+--------------------------------------+---------+-------------+-------------+ | mark | wait/io/file/myisam/dfile | 19540 | 215.20 ms | 120.79 ms | | mark | wait/io/file/myisam/kfile | 501 | 131.58 ms | 57.74 ms | | mark | wait/io/file/sql/dbopt | 2 | 17.29 us | 9.17 us | | root | wait/io/file/innodb/innodb_log_file | 2079432 | 00:28:27.62 | 1.30 s | | root | wait/io/file/myisam/kfile | 5195927 | 00:17:07.33 | 1.17 s | | root | wait/io/file/myisam/dfile | 1533813 | 00:07:27.59 | 1.18 s | | root | wait/io/file/sql/binlog | 3517008 | 00:03:07.34 | 1.42 s | | root | wait/io/file/innodb/innodb_data_file | 20720 | 00:02:37.81 | 492.23 ms | | root | wait/io/file/sql/FRM | 41412 | 3.17 s | 80.43 ms | | root | wait/io/file/sql/dbopt | 110993 | 1.23 s | 63.27 ms |
  • 40. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | user_summary_by_statement_latency view mysql> select * from user_summary_by_statement_latencyG *************************** 1. row *************************** user: mark total: 176 total_latency: 1.26 s max_latency: 583.33 ms lock_latency: 216.95 ms rows_sent: 311 rows_examined: 307 rows_affected: 0 full_scans: 7
  • 41. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | user_summary_by_statement_type view mysql> select * from user_summary_by_statement_typeG *************************** 1. row *************************** user: mark statement: commit total: 2463190 total_latency: 13.33h max_latency: 12.18 s lock_latency: 0 ps rows_sent: 0 rows_examined: 0 rows_affected: 0 full_scans: 0
  • 42. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • IO by current threads • Global summaries by file and class, aggregating by bytes or latency • Stream of last file IO events in raw form 42 IO Summary Views io_by_thread_by_latency io_global_by_file_by_bytes io_global_by_file_by_latency io_global_by_wait_by_bytes io_global_by_wait_by_latency
  • 43. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | io_by_thread_by_latency view mysql> select * from io_by_thread_by_latencyG *************************** 1. row *************************** user: main total: 1193 total_latency: 136.45 ms min_latency: 731.38 ns avg_latency: 269.99 us max_latency: 20.72 ms thread_id: 1 processlist_id: NULL *************************** 2. row *************************** user: root@localhost total: 533 total_latency: 53.81 ms min_latency: 780.39 ns avg_latency: 8.41 ms max_latency: 25.06 ms thread_id: 23 processlist_id: 4
  • 44. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | io_global_by_file_by_latency view mysql> select * from io_global_by_file_by_latency limit 1G *************************** 1. row *************************** file: @@datadir/ibdata1 total: 1395714 total_latency: 00:28:53.06 count_read: 1006 read_latency: 4.51 s count_write: 1326529 write_latency: 33.39 s count_misc: 68179 misc_latency: 00:28:15.16
  • 45. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | latest_file_io view mysql> select * from latest_file_io; +-----------------------------+----------------------------------+-----------+-----------+-----------+ | thread | file | latency | operation | requested | +-----------------------------+----------------------------------+-----------+-----------+-----------+ | root@localhost:63153:179371 | @@datadir/ib_logfile1 | 7.16 us | lock | NULL | | root@localhost:63153:179371 | @@datadir/ib_logfile1 | 6.16 us | write | 1.50 KiB | | root@localhost:63153:179371 | @@datadir/ib_logfile1 | 14.36 ms | sync | NULL | | root@localhost:63153:179371 | @@datadir/cerberus-bin.000012 | 28.25 us | write | 905 bytes | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 15.25 us | write | 1.00 KiB | | root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 32.12 us | read | 905 bytes | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 6.65 us | write | 1.00 KiB | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 213.32 us | sync | NULL | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 17.27 us | write | 1.00 KiB | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 286.01 us | sync | NULL | | root@localhost:63177:179394 | @@datadir/cerberus-bin.000012 | 18.77 us | write | 601 bytes | | root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 7.55 us | read | 601 bytes | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 10.67 us | write | 1.00 KiB | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 200.28 us | sync | NULL | | root@localhost:63177:179394 | @@datadir/cerberus-bin.000012 | 12.91 us | write | 601 bytes | | root@localhost:57487:3 | @@datadir/cerberus-bin.000012 | 6.47 us | read | 601 bytes | | root@localhost:63177:179394 | @@datadir/ib_logfile1 | 9.22 us | write | 1.50 KiB | ……
  • 46. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Object overview • Table usage statistics • Index usage statistics • Following show users only 46 Schema Analysis Views schema_index_statistics schema_object_overview schema_table_statistics schema_table_statistics_with_buffer schema_tables_with_full_table_scans schema_unused_indexes
  • 47. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | schema_table_statistics view mysql> select * from schema_table_statistics limit 1G *************************** 1. row *************************** table_schema: mem__quan table_name: normalized_statements_by_server_by_schema_data total_latency: 00:55:07.80 rows_fetched: 239685 fetch_latency: 17.10 s rows_inserted: 1102895 insert_latency: 00:52:18.10 rows_updated: 55910 update_latency: 00:02:28.62 rows_deleted: 17899 delete_latency: 3.98 s io_read_requests: 20639 io_read: 324.94 MiB io_read_latency: 00:03:04.10 io_write_requests: 1965973 io_write: 40.36 GiB io_write_latency: 25.46 s io_misc_requests: 18217 io_misc_latency: 00:14:06.02
  • 48. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | schema_index_statistics view mysql> select * from schema_index_statistics limit 1G *************************** 1. row *************************** table_schema: mem__inventory table_name: mysqlconnectionconfiguration index_name: PRIMARY rows_selected: 131399 select_latency: 00:07:05.03 rows_inserted: 0 insert_latency: 0 ps rows_updated: 41608 update_latency: 21.96 s rows_deleted: 0 delete_latency: 0 ps
  • 49. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | schema_tables_with_full_table_scans view mysql> select * from schema_tables_with_full_table_scans limit 10; +--------------------+--------------------------------+-------------------+-----------+ | object_schema | object_name | rows_full_scanned | latency | +--------------------+--------------------------------+-------------------+-----------+ | mem30__instruments | fsstatistics | 10207042 | 13.10 s | | mem30__instruments | preparedstatementapidata | 436428 | 973.27 ms | | mem30__instruments | mysqlprocessactivity | 411702 | 282.07 ms | | mem30__instruments | querycachequeriesincachedata | 374011 | 767.15 ms | | mem30__instruments | rowaccessesdata | 322321 | 1.55 s | | mem30__instruments | connectionsmaxdata | 301242 | 857.63 ms | | mem30__instruments | innodbdatadictionarymemorydata | 292564 | 495.38 ms | | mem30__instruments | innodbbufferpooldata | 277112 | 1.95 s | | mem30__instruments | avgrowaccessesdata | 269236 | 1.25 s | | mem30__instruments | innodbrowdetailsdata | 248208 | 653.25 ms | +--------------------+--------------------------------+-------------------+-----------+
  • 50. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | schema_unused_indexes view mysql> select * from schema_unused_indexes limit 10; +--------------------+-----------------------------------+--------------------+ | object_schema | object_name | index_name | +--------------------+-----------------------------------+--------------------+ | mem30__bean_config | plists | path | | mem30__config | group_selections | name | | mem30__config | notification_groups | name | | mem30__config | user_form_defaults | FKC1AEF1F9E7EE2CFB | | mem30__enterprise | whats_new_entries | entryId | | mem30__events | action_logs | policyId | | mem30__events | action_logs | eventId | | mem30__events | action_logs | ts | | mem30__events | advisor_scopes_advisorcategoryids | FKF0CB0DB962CAB4 | | mem30__events | advisor_scopes_advisorclassids | FK650AF1BF962CAB4 | +--------------------+-----------------------------------+--------------------+ You should ensure you have representative time frame before taking any actions!
  • 51. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Wait summaries by class • Wait details per: • User • Host • Globally 51 Wait Analysis Views wait_classes_global_by_avg_latency wait_classes_global_by_latency waits_by_host_by_latency waits_by_user_by_latency waits_global_by_latency
  • 52. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | waits_global_by_latency view mysql> select * from waits_global_by_latency limit 10; +--------------------------------------+----------+---------------+-------------+-------------+ | events | total | total_latency | avg_latency | max_latency | +--------------------------------------+----------+---------------+-------------+-------------+ | wait/io/table/sql/handler | 24196659 | 1.75h | 259.72 us | 2.29 s | | wait/io/file/innodb/innodb_data_file | 5964255 | 1.36h | 822.01 us | 1.49 s | | wait/io/file/innodb/innodb_log_file | 2272647 | 00:36:41.37 | 968.64 us | 1.30 s | | wait/io/file/myisam/kfile | 5463587 | 00:18:14.16 | 200.26 us | 1.17 s | | wait/io/file/myisam/dfile | 1715187 | 00:08:00.18 | 279.96 us | 1.18 s | | wait/io/file/sql/binlog | 3722079 | 00:03:23.71 | 54.73 us | 1.42 s | | wait/lock/table/sql/handler | 10074274 | 00:01:56.63 | 11.58 us | 186.90 ms | | wait/io/socket/sql/client_connection | 3879827 | 25.36 s | 6.54 us | 219.25 ms | | wait/io/file/sql/FRM | 43994 | 3.27 s | 74.35 us | 80.43 ms | | wait/io/file/sql/dbopt | 116765 | 1.29 s | 11.03 us | 63.27 ms | +--------------------------------------+----------+---------------+-------------+-------------+ InnoDB only instance, this MyISAM IO is all temporary tables, focus tuning there!
  • 53. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | waits_by_user_by_latency view mysql> select * from waits_by_user_by_latency; +------+--------------------------------------+----------+---------------+-------------+-------------+ | user | event | total | total_latency | avg_latency | max_latency | +------+--------------------------------------+----------+---------------+-------------+-------------+ | mark | wait/io/file/myisam/dfile | 19540 | 215.20 ms | 11.01 us | 120.79 ms | | mark | wait/io/file/myisam/kfile | 501 | 131.58 ms | 262.63 us | 57.74 ms | | mark | wait/io/file/sql/dbopt | 2 | 17.29 us | 8.64 us | 9.17 us | | root | wait/io/table/sql/handler | 24189319 | 1.74h | 258.77 us | 2.29 s | | root | wait/io/file/innodb/innodb_log_file | 2162650 | 00:30:52.87 | 856.76 us | 1.30 s | | root | wait/io/file/myisam/kfile | 5460992 | 00:18:12.83 | 200.11 us | 1.17 s | | root | wait/io/file/myisam/dfile | 1694624 | 00:07:59.50 | 282.95 us | 1.18 s | | root | wait/io/file/sql/binlog | 3711637 | 00:03:23.16 | 54.74 us | 1.42 s | | root | wait/io/file/innodb/innodb_data_file | 22577 | 00:03:05.73 | 8.23 ms | 492.23 ms | | root | wait/lock/table/sql/handler | 10069000 | 00:01:56.59 | 11.58 us | 186.90 ms | …… root is doing the most temporary table IO
  • 54. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Table Metadata Lock Waits • InnoDB Row Lock Waits 54 Lock Wait Views schema_table_lock_waits innodb_lock_waits
  • 55. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | sys.schema_table_lock_waits mysql> select * from sys.schema_table_lock_waitsG *************************** 1. row *************************** object_schema: test object_name: t waiting_thread_id: 43 waiting_pid: 21 waiting_account: msandbox@localhost waiting_lock_type: SHARED_UPGRADABLE waiting_lock_duration: TRANSACTION waiting_query: alter table test.t add foo int waiting_query_secs: 988 waiting_query_rows_affected: 0 waiting_query_rows_examined: 0 blocking_thread_id: 42 blocking_pid: 20 blocking_account: msandbox@localhost blocking_lock_type: SHARED_NO_READ_WRITE blocking_lock_duration: TRANSACTION sql_kill_blocking_query: KILL QUERY 20 sql_kill_blocking_connection: KILL 20
  • 56. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | sys.innodb_lock_waits mysql> SELECT * FROM sys.innodb_lock_waitsG *************************** 1. row *************************** wait_started: 2014-11-11 13:39:20 wait_age: 00:00:07 wait_age_secs: 7 locked_table: `db1`.`t1` locked_index: PRIMARY locked_type: RECORD waiting_trx_id: 867158 waiting_trx_started: 2014-11-11 13:39:15 waiting_trx_age: 00:00:12 waiting_trx_rows_locked: 0 waiting_trx_rows_modified: 0 waiting_pid: 3 waiting_query: UPDATE t1 SET val = val + 1 WHERE id = 2 waiting_lock_id: 867158:2363:3:3 waiting_lock_mode: X blocking_trx_id: 867157 blocking_pid: 4 ... blocking_query: UPDATE t1 SET val … blocking_lock_id: 867157:2363:3:3 blocking_lock_mode: X blocking_trx_started: 2014-11-11 13:39:11 blocking_trx_age: 00:00:16 blocking_trx_rows_locked: 1 blocking_trx_rows_modified: 1 sql_kill_blocking_query: KILL QUERY 4 sql_kill_blocking_connection: KILL 4
  • 57. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Statement overview • Find statements by: • Those with errors • Those with full table scans • Those creating temp tables • Those that cause sorting • With latency in 95th %ile 57 Statement Analysis Views statement_analysis statements_with_errors_or_warnings statements_with_full_table_scans statements_with_runtimes_in_95th_p ercentile statements_with_sorting statements_with_temp_tables
  • 58. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | statement_analysis view mysql> select * from statement_analysis limit 2G *************************** 1. row *************************** query: INSERT INTO `mem30__quan` . `n ... nDuration` = IF ( VALUES ( ... db: mem full_scan: exec_count: 4657 err_count: 0 warn_count: 0 total_latency: 00:03:57.40 max_latency: 10.54 s avg_latency: 50.98 ms lock_latency: 00:03:00.93 rows_sent: 0 rows_sent_avg: 0 rows_examined: 0 rows_examined_avg: 0 rows_affected: 4794 rows_affected_avg: 1 tmp_tables: 0 tmp_disk_tables: 0 rows_sorted: 0 sort_merge_passes: 0 digest: b98bfe333642e8e4e72c73515810d865 first_seen: 2014-09-24 11:27:01 last_seen: 2014-09-24 11:53:00
  • 59. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | statements_with_errors_or_warnings view mysql> select * from statements_with_errors_or_warnings limit 1G *************************** 1. row *************************** query: CREATE TEMPORARY TABLE IF NOT ... _logs` ( `id` INT8 NOT NULL ) db: mem exec_count: 1725 errors: 1725 error_pct: 100.0000 warnings: 0 warning_pct: 0.0000 first_seen: 2014-05-20 10:42:32 last_seen: 2014-05-21 18:39:22 digest: 51fb979dbc3910a6294c7cdabd7839c3
  • 60. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | statements_with_temp_tables view mysql> select * from statements_with_temp_tables limit 1G *************************** 1. row *************************** query: SELECT * FROM ( SELECT `digest ... ` , `sum_no_index_used` AS ... db: mysql exec_count: 68 total_latency: 2.31 s memory_tmp_tables: 476 disk_tmp_tables: 204 avg_tmp_tables_per_query: 7 tmp_tables_to_disk_pct: 43 first_seen: 2014-09-24 11:26:18 last_seen: 2014-09-24 12:33:00 digest: 50761c6a1818824328745d8a136b9ed6
  • 61. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | statements_with_full_table_scans view mysql> select * from statements_with_full_table_scans limit 1G *************************** 1. row *************************** query: SELECT `pojotimese0_` . `id` A ... ty_timeseries` `pojotimese0_` db: mem exec_count: 1 total_latency: 940.89 us no_index_used_count: 1 no_good_index_used_count: 0 no_index_used_pct: 100 rows_sent: 116 rows_examined: 116 rows_sent_avg: 116 rows_examined_avg: 116 first_seen: 2014-09-24 11:25:03 last_seen: 2014-09-24 11:25:03 digest: f81b5ce10baee9be754cf35fd245a516
  • 62. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | • Better SHOW PROCESSLIST • No mutex contention • Live statistics for query • Consolidated metrics 62 Miscellaneous Views processlist session metrics
  • 63. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | processlist / session views mysql> select * from sessionG *************************** 1. row *************************** thd_id: 7890 conn_id: 7870 user: root@localhost db: mem command: Query state: update time: 0 current_statement: /* mem dbpool.default */ inser ...<truncated> lock_latency: 0 ps rows_examined: 0 rows_sent: 0 rows_affected: 0 tmp_tables: 0 tmp_disk_tables: 0 full_scan: NO last_statement: NULL last_statement_latency: NULL last_wait: wait/io/table/sql/handler last_wait_latency: Still Waiting source: handler.cc:7274
  • 64. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | sys.sessions progress estimation mysql> select * from sys.sessionsG *************************** 1. row *************************** thd_id: 44524 conn_id: 44502 user: msandbox@localhost db: test command: Query state: alter table (flush) time: 18 current_statement: alter table t1 add column g int statement_latency: 18.45 s progress: 98.84 lock_latency: 265.43 ms rows_examined: 0 rows_sent: 0 rows_affected: 0 tmp_tables: 0 tmp_disk_tables: 0 ...
  • 65. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | sys.metrics mysql> select * from sys.metrics limit 199, 10; +-----------------------------+----------------+--------------------------------------+---------+ | Variable_name | Variable_value | Type | Enabled | +-----------------------------+----------------+--------------------------------------+---------+ | tc_log_page_waits | 0 | Global Status | YES | | threads_cached | 7 | Global Status | YES | | threads_connected | 3 | Global Status | YES | | threads_created | 10 | Global Status | YES | | threads_running | 3 | Global Status | YES | | uptime | 275689 | Global Status | YES | | uptime_since_flush_status | 275689 | Global Status | YES | | adaptive_hash_pages_added | 0 | InnoDB Metrics - adaptive_hash_index | NO | | adaptive_hash_pages_removed | 0 | InnoDB Metrics - adaptive_hash_index | NO | | adaptive_hash_rows_added | 0 | InnoDB Metrics - adaptive_hash_index | NO | +-----------------------------+----------------+--------------------------------------+---------+ performance_schema.global_status information_schema.innodb_metrics
  • 66. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |