sys
sys
sys
--initialize
--initialize-insecure
sys
sys
version
sys
sys
'mysql.sys'@'localhost'
root
sys
sys
sys
sys
INSERT
UPDATE
sys_config
sys
ps_setup_save()
sys
sys
wait
stage
statement
xxx
_currentxxx
sys
呼叫系统。ps_setup_enable_instrument(等待');呼叫系统。ps_setup_enable_instrument('stage ');呼叫系统。ps_setup_enable_instrument(表”);呼叫系统。ps_setup_enable_consumer(当前的);呼叫系统。ps_setup_enable_consumer('history_long”);
sys
呼叫系统。ps_setup_reset_to_default(真的);
sys
MySQL的> USE sys;
数据库changedmysql > SELECT * FROM version;
------------- --------------------- | sys_version | mysql_version | ------------- --------------------- | 1.6.0 | 8.0.2-dmr-debug-log | ------------- ---------------------
version
sys
sys
MySQL的> SELECT * FROM sys.version;
------------- --------------------- | sys_version | mysql_version | ------------- --------------------- | 1.6.0 | 8.0.2-dmr-debug-log | ------------- ---------------------
sys
sys
host_summary_by_file_io
MySQL的> SELECT * FROM host_summary_by_file_io;
------------ ------- ------------ |主机| iOS | io_latency | ------------ ------- ------------ | localhost | 67570 | 5.38 | |背景| 3468 | 4.18 | ------------ ------- ------------
x$host_summary_by_file_io
MySQL的> SELECT * FROM x$host_summary_by_file_io;
------------ ------- --------------- |主机| iOS | io_latency | ------------ ------- --------------- | localhost | 67574 | 5380678125144 | |背景| 3474 | 4758696829416 | ------------ ------- ---------------
x$
x$
sys
SHOW
INFORMATION_SCHEMA
session
format_bytes()
MySQL的> SHOW CREATE VIEW session;
MySQL的> SHOW CREATE FUNCTION format_bytes;
.sql
sys
sys
sys
mysqldump --databases --routines sys > sys_dump.sqlmysqlpump sys > sys_dump.sql
mysql < sys_dump.sql
sys
processlistsessionx processlistx美元$ SESSION
progress
events_stages_current
阶段/ SQL /复制到TMP tablestage / InnoDB /修改表(结束)阶段/ InnoDB /修改表(冲洗)阶段/ InnoDB /修改表(插入)阶段/ InnoDB /修改表(log应用指数)阶段/ InnoDB /修改表(日志申请表)阶段/ InnoDB /修改表(合并排序)阶段/ InnoDB /修改表(读PK和内部排序)阶段/ InnoDB缓冲池的负荷/
progress
sys
sys
sys_config | sys |
sys_config_insert_set_user | sys_config |
sys_config_update_set_user | sys_config |
create_synonym_db() | |
diagnostics() | |
execute_prepared_stmt() | |
ps_setup_disable_background_threads() | |
ps_setup_disable_consumer() | |
ps_setup_disable_instrument() | |
ps_setup_disable_thread() | |
ps_setup_enable_background_threads() | |
ps_setup_enable_consumer() | |
ps_setup_enable_instrument() | |
ps_setup_enable_thread() | |
ps_setup_reload_saved() | |
ps_setup_reset_to_default() | |
ps_setup_save() | |
ps_setup_show_disabled() | |
ps_setup_show_disabled_consumers() | |
ps_setup_show_disabled_instruments() | |
ps_setup_show_enabled() | |
ps_setup_show_enabled_consumers() | |
ps_setup_show_enabled_instruments() | |
ps_statement_avg_latency_histogram() | |
ps_trace_statement_digest() | |
ps_trace_thread() | |
ps_truncate_all_tables() | |
statement_performance_analyzer() | |
table_exists() |
extract_schema_from_file_name() | |
extract_table_from_file_name() | |
format_bytes() | |
format_path() | |
format_statement() | |
format_time() | |
list_add() | |
list_drop() | |
ps_is_account_enabled() | |
ps_is_consumer_enabled() | |
ps_is_instrument_default_enabled() | |
ps_is_instrument_default_timed() | |
ps_is_thread_instrumented() | |
ps_thread_account() | |
ps_thread_id() | |
ps_thread_stack() | |
ps_thread_trx_info() | |
quote_identifier() | |
sys_get_config() | sys |
version_major() | |
version_minor() | |
version_patch() |
sys
sys
sys_config
variable
value
set_time
set_by
NULL
sys
sys_config
sys
diagnostics.include_raw
NULL
sys_config
statement_truncate_len
format_statement()
mysql>SET @stmt = 'SELECT variable, value, set_time, set_by FROM sys_config';
mysql>SELECT format_statement(@stmt);
+----------------------------------------------------------+ | format_statement(@stmt) | +----------------------------------------------------------+ | SELECT variable, value, set_time, set_by FROM sys_config | +----------------------------------------------------------+ mysql>SET @sys.statement_truncate_len = 32;
mysql>SELECT format_statement(@stmt);
+-----------------------------------+ | format_statement(@stmt) | +-----------------------------------+ | SELECT variabl ... ROM sys_config | +-----------------------------------+
format_statement()
NULL
MySQL的> SET @sys.statement_truncate_len = NULL;
MySQL的> SELECT format_statement(@stmt);
---------------------------------------------------------- | format_statement(@ STMT)| ---------------------------------------------------------- |选择变量值,set_time,set_by从sys_config | ----------------------------------------------------------
sys_config
sys_config
diagnostics.allow_i_s_tables
ON
diagnostics()
INFORMATION_SCHEMA.TABLES
diagnostics.include_raw
ON
diagnostics()
metrics
ps_thread_trx_info.max_length
ps_thread_trx_info()
statement_performance_analyzer.limit
statements_with_runtimes_in_95th_percentile
statement_performance_analyzer.view
statement_performance_analyzer()
diagnostics()
events_statements_summary_by_digest
statement_performance_analyzer.limit
statement_truncate_len
format_statement()
sys_config
diagnostics()
execute_prepared_stmt()
sys_config
mysql> INSERT INTO sys_config (variable, value) VALUES('debug', 'ON');
mysql> UPDATE sys_config SET value = 'OFF' WHERE variable = 'debug';
NULL
MySQL的> SET @sys.debug = NULL;
sys_config
sys_config_insert_set_user
sys_config_update_set_user
sys_config
sys_config_insert_set_user
UPDATE
sys
sys
host_summary_by_file_io
MySQL的> SELECT * FROM host_summary_by_file_io;
------------ ------- ------------ |主机| iOS | io_latency | ------------ ------- ------------ | localhost | 67570 | 5.38 | |背景| 3468 | 4.18 | ------------ ------- ------------
x$host_summary_by_file_io
MySQL的> SELECT * FROM x$host_summary_by_file_io;
------------ ------- --------------- |主机| iOS | io_latency | ------------ ------- --------------- | localhost | 67574 | 5380678125144 | |背景| 3474 | 4758696829416 | ------------ ------- ---------------
x$
x$
format_bytes()
format_time()
format_statement()
format_path()
host_summary
x$host_summary
host
HOST
background
statements
statement_latency
statement_avg_latency
table_scans
file_ios
file_io_latency
current_connections
total_connections
unique_users
current_memory
total_memory_allocated
host_summary_by_file_io
x$host_summary_by_file_io
host
HOST
background
ios
io_latency
host_summary_by_file_io_type
x$host_summary_by_file_io_type
host
HOST
background
event_name
total
total_latency
max_latency
host_summary_by_stages
x$host_summary_by_stages
host
HOST
background
event_name
total
total_latency
avg_latency
host_summary_by_statement_latency
x$host_summary_by_statement_latency
host
HOST
background
total
total_latency
max_latency
lock_latency
rows_sent
rows_examined
rows_affected
full_scans
host_summary_by_statement_type
x$host_summary_by_statement_type
host
HOST
background
statement
total
total_latency
max_latency
lock_latency
rows_sent
rows_examined
rows_affected
full_scans
INFORMATION_SCHEMA
INNODB_BUFFER_PAGE
INNODB_BUFFER_PAGE
innodb_buffer_stats_by_schema
x$innodb_buffer_stats_by_schema
object_schema
InnoDB
System
allocated
data
pages
pages_hashed
pages_old
rows_cached
INFORMATION_SCHEMA
INNODB_BUFFER_PAGE
INNODB_BUFFER_PAGE
innodb_buffer_stats_by_table
x$innodb_buffer_stats_by_table
object_schema
InnoDB
System
object_name
allocated
data
pages
pages_hashed
pages_old
rows_cached
InnoDB
innodb_lock_waits
x$innodb_lock_waits
wait_started
wait_age
TIME
wait_age_secs
locked_table_schema
locked_table_name
locked_table_partition
NULL
locked_table_subpartition
NULL
locked_index
locked_type
waiting_trx_id
waiting_trx_started
waiting_trx_age
TIME
waiting_trx_rows_locked
waiting_trx_rows_modified
waiting_pid
waiting_query
waiting_lock_id
waiting_lock_mode
blocking_trx_id
blocking_pid
blocking_query
blocking_lock_id
blocking_lock_mode
blocking_trx_started
blocking_trx_age
TIME
blocking_trx_rows_locked
blocking_trx_rows_modified
sql_kill_blocking_query
KILL
sql_kill_blocking_connection
KILL
io_by_thread_by_latency
x$io_by_thread_by_latency
user
total
total_latency
min_latency
avg_latency
max_latency
thread_id
processlist_id
NULL
io_global_by_file_by_bytes
x$io_global_by_file_by_bytes
file
count_read
total_read
avg_read
count_write
total_written
avg_write
total
write_pct
io_global_by_file_by_latency
x$io_global_by_file_by_latency
file
total
total_latency
count_read
read_latency
count_write
write_latency
count_misc
misc_latency
io_global_by_wait_by_bytes
x$io_global_by_wait_by_bytes
event_name
wait/io/file/
total
total_latency
min_latency
avg_latency
max_latency
count_read
total_read
avg_read
count_write
total_written
avg_written
total_requested
io_global_by_wait_by_latency
x$io_global_by_wait_by_latency
event_name
wait/io/file/
total
total_latency
avg_latency
max_latency
read_latency
write_latency
misc_latency
count_read
total_read
avg_read
count_write
total_written
avg_written
latest_file_io
x$latest_file_io
thread
file
latency
operation
requested
memory_by_host_by_current_bytes
x$memory_by_host_by_current_bytes
host
HOST
background
current_count_used
current_allocated
current_avg_alloc
current_max_alloc
total_allocated
memory_by_thread_by_current_bytes
x$memory_by_thread_by_current_bytes
thread_id
user
current_count_used
current_allocated
current_avg_alloc
current_max_alloc
total_allocated
memory_by_user_by_current_bytes
x$memory_by_user_by_current_bytes
user
USER
background
current_count_used
current_allocated
current_avg_alloc
current_max_alloc
total_allocated
memory_global_by_current_bytes
x$memory_global_by_current_bytes
event_name
current_count
current_alloc
current_avg_alloc
high_count
high_alloc
high_avg_alloc
metrics
global_status
InnoDB
INNODB_METRICS
global_status
INNODB_METRICS
metrics
metrics
Variable_name
VARIABLE_NAME
global_status
InnoDB
INNODB_METRICS
Variable_value
VARIABLE_VALUE
global_status
InnoDB
INNODB_METRICS
memory_summary_global_by_event_name
NOW(3)
UNIX_TIMESTAMP(NOW(3))
Type
Global
Status
InnoDB
%
INNODB_METRICS
Performance
Schema
System Time
Enabled
YES
InnoDB
STATUS
INNODB_METRICS
NO
NO
PARTIAL
memory/%
YES
SHOW
PROCESSLIST
PROCESSLIST
threads
processlist
x$processlist
thd_id
conn_id
user
db
NULL
command
Sleep
state
time
current_statement
NULL
statement_latency
progress
lock_latency
rows_examined
rows_sent
rows_affected
tmp_tables
tmp_disk_tables
full_scan
last_statement
last_statement_latency
current_memory
last_wait
last_wait_latency
source
trx_latency
trx_state
trx_autocommit
pid
program_name
ps_check_lost_instrumentation
variable_name
variable_value
AUTO_INCREMENT
mysql
INFORMATION_SCHEMA
schema_auto_increment_columns
table_schema
table_name
AUTO_INCREMENT
column_name
AUTO_INCREMENT
data_type
column_type
bigint(20) unsigned
is_signed
is_unsigned
max_value
auto_increment
AUTO_INCREMENT
auto_increment_ratio
schema_index_statistics
x$schema_index_statistics
table_schema
table_name
index_name
rows_selected
select_latency
rows_inserted
insert_latency
rows_updated
update_latency
rows_deleted
delete_latency
schema_object_overview
db
object_type
BASE TABLE
index_type
FUNCTION
TRIGGER
count
schema_redundant_indexes
x$schema_flattened_keys
schema_redundant_indexes
schema_redundant_indexes
table_schema
table_name
redundant_index_name
redundant_index_columns
redundant_index_non_unique
dominant_index_name
dominant_index_columns
dominant_index_non_unique
subpart_exists
sql_drop_index
x$schema_flattened_keys
table_schema
table_name
index_name
non_unique
subpart_exists
index_columns
metadata_locks
schema_table_lock_waits
x$schema_table_lock_waits
object_schema
object_name
waiting_thread_id
waiting_pid
waiting_account
waiting_lock_type
waiting_lock_duration
waiting_query
waiting_query_secs
waiting_query_rows_affected
waiting_query_rows_examined
blocking_thread_id
blocking_pid
blocking_account
blocking_lock_type
blocking_lock_duration
sql_kill_blocking_query
KILL
sql_kill_blocking_connection
KILL
x$ps_schema_table_statistics_io
schema_table_statistics
x$schema_table_statistics
table_schema
table_name
total_latency
rows_fetched
fetch_latency
rows_inserted
insert_latency
rows_updated
update_latency
rows_deleted
delete_latency
io_read_requests
io_read
io_read_latency
io_write_requests
io_write
io_write_latency
io_misc_requests
io_misc_latency
InnoDB
x$ps_schema_table_statistics_io
schema_table_statistics_with_buffer
x$schema_table_statistics_with_buffer
table_schema
table_name
rows_fetched
fetch_latency
rows_inserted
insert_latency
rows_updated
update_latency
rows_deleted
delete_latency
io_read_requests
io_read
io_read_latency
io_write_requests
io_write
io_write_latency
io_misc_requests
io_misc_latency
innodb_buffer_allocated
InnoDB
innodb_buffer_data
InnoDB
innodb_buffer_free
InnoDB
innodb_buffer_data
innodb_buffer_pages
InnoDB
innodb_buffer_pages_hashed
InnoDB
innodb_buffer_pages_old
InnoDB
innodb_buffer_rows_cached
InnoDB
schema_tables_with_full_table_scans
x$schema_tables_with_full_table_scans
object_schema
object_name
rows_full_scanned
latency
schema_unused_indexes
object_schema
object_name
index_name
session_ssl_status
thread_id
ssl_version
ssl_cipher
ssl_sessions_reused
statement_analysis
x$statement_analysis
query
db
NULL
full_scan
exec_count
err_count
warn_count
total_latency
max_latency
avg_latency
lock_latency
rows_sent
rows_sent_avg
rows_examined
rows_examined_avg
rows_affected
rows_affected_avg
tmp_tables
tmp_disk_tables
rows_sorted
sort_merge_passes
digest
first_seen
last_seen
statements_with_errors_or_warnings
x$statements_with_errors_or_warnings
query
db
NULL
exec_count
errors
error_pct
warnings
warning_pct
first_seen
last_seen
digest
statements_with_full_table_scans
x$statements_with_full_table_scans
query
db
NULL
exec_count
total_latency
no_index_used_count
no_good_index_used_count
no_index_used_pct
rows_sent
rows_examined
rows_sent_avg
rows_examined_avg
first_seen
last_seen
digest
x$ps_digest_avg_latency_distribution
statements_with_runtimes_in_95th_percentile
x$statements_with_runtimes_in_95th_percentile
query
db
NULL
full_scan
exec_count
err_count
warn_count
total_latency
max_latency
avg_latency
rows_sent
rows_sent_avg
rows_examined
rows_examined_avg
first_seen
last_seen
digest
statements_with_sorting
x$statements_with_sorting
query
db
NULL
exec_count
total_latency
sort_merge_passes
avg_sort_merges
sorts_using_scans
sort_using_range
rows_sorted
avg_rows_sorted
first_seen
last_seen
digest
statements_with_temp_tables
x$statements_with_temp_tables
query
db
NULL
exec_count
total_latency
memory_tmp_tables
disk_tmp_tables
avg_tmp_tables_per_query
tmp_tables_to_disk_pct
first_seen
last_seen
digest
user_summary
x$user_summary
user
USER
background
statements
statement_latency
statement_avg_latency
table_scans
file_ios
file_io_latency
current_connections
total_connections
unique_hosts
current_memory
total_memory_allocated
user_summary_by_file_io
x$user_summary_by_file_io
user
USER
background
ios
io_latency
user_summary_by_file_io_type
x$user_summary_by_file_io_type
user
USER
background
event_name
total
latency
max_latency
user_summary_by_stages
x$user_summary_by_stages
user
USER
background
event_name
total
total_latency
avg_latency
user_summary_by_statement_latency
x$user_summary_by_statement_latency
user
USER
background
total
total_latency
max_latency
lock_latency
rows_sent
rows_examined
rows_affected
full_scans
user_summary_by_statement_type
x$user_summary_by_statement_type
user
USER
background
statement
total
total_latency
max_latency
lock_latency
rows_sent
rows_examined
rows_affected
full_scans
wait/io/file/sql/slow_log
wait_classes_global_by_avg_latency
x$wait_classes_global_by_avg_latency
event_class
total
total_latency
min_latency
avg_latency
max_latency
wait/io/file/sql/slow_log
wait_classes_global_by_latency
x$wait_classes_global_by_latency
event_class
total
total_latency
min_latency
avg_latency
max_latency
waits_by_host_by_latency
x$waits_by_host_by_latency
host
event
total
total_latency
avg_latency
max_latency
waits_by_user_by_latency
x$waits_by_user_by_latency
user
event
total
total_latency
avg_latency
max_latency
waits_global_by_latency
x$waits_global_by_latency
events
total
total_latency
avg_latency
max_latency
sys
info
in_db_name VARCHAR(64)
in_synonym VARCHAR(64)
mysql>SHOW DATABASES;
+--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | world | +--------------------+ mysql>CALL create_synonym_db('INFORMATION_SCHEMA', 'info');
+---------------------------------------+ | summary | +---------------------------------------+ | Created 63 views in the info database | +---------------------------------------+ mysql>SHOW DATABASES;
+--------------------+ | Database | +--------------------+ | information_schema | | info | | mysql | | performance_schema | | sys | | world | +--------------------+ mysql>SHOW FULL TABLES FROM info;
+---------------------------------------+------------+ | Tables_in_info | Table_type | +---------------------------------------+------------+ | character_sets | VIEW | | collation_character_set_applicability | VIEW | | collations | VIEW | | column_privileges | VIEW | | columns | VIEW | ...
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
diagnostics()
metrics
sys
ndbinfo
diagnostics()
ON
diagnostics()
metrics
in_max_runtime INT UNSIGNED
in_interval INT UNSIGNED
in_auto_config ENUM('current', 'medium',
'full')
current
medium
full
medium
medium
SUPER
current
diagnostics()
debug
ON
diagnostics.allow_i_s_tables
ON
diagnostics()
INFORMATION_SCHEMA.TABLES
diagnostics.include_raw
ON
diagnostics()
metrics
statement_truncate_len
format_statement()
mysql> CALL diagnostics(120, 30, 'current');
diagnostics()
tee
filename
mysql>tee diag.out;
mysql>CALL diagnostics(120, 30, 'current');
mysql>notee;
sys_execute_prepared_stmt
execute_prepared_stmt()
debug
ON
consumer VARCHAR(128)
LIKE
''
in_pattern VARCHAR(128)
LIKE
''
mysql> CALL ps_setup_disable_instrument('wait/lock/metadata/sql/mdl');
+-----------------------+
| summary |
+-----------------------+
| Disabled 1 instrument |
+-----------------------+
mysql> CALL ps_setup_disable_instrument('mutex');
+--------------------------+
| summary |
+--------------------------+
| Disabled 177 instruments |
+--------------------------+
in_connection_id BIGINT
threads
SHOW PROCESSLIST
mysql> CALL ps_setup_disable_thread(225);
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
mysql> CALL ps_setup_disable_thread(CONNECTION_ID());
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
consumer VARCHAR(128)
LIKE
''
in_pattern VARCHAR(128)
LIKE
''
mysql> CALL ps_setup_enable_instrument('wait/lock/metadata/sql/mdl');
+----------------------+
| summary |
+----------------------+
| Enabled 1 instrument |
+----------------------+
mysql> CALL ps_setup_enable_instrument('mutex');
+-------------------------+
| summary |
+-------------------------+
| Enabled 177 instruments |
+-------------------------+
in_connection_id BIGINT
threads
SHOW PROCESSLIST
mysql> CALL ps_setup_enable_thread(225);
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
mysql> CALL ps_setup_enable_thread(CONNECTION_ID());
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
ps_setup_save()
ps_setup_save()
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
mysql> CALL ps_setup_reset_to_default(TRUE)\G
*************************** 1. row ***************************
status: Resetting: setup_actors
DELETE
FROM performance_schema.setup_actors
WHERE NOT (HOST = '%' AND USER = '%' AND ROLE = '%')
*************************** 1. row ***************************
status: Resetting: setup_actors
INSERT IGNORE INTO performance_schema.setup_actors
VALUES ('%', '%', '%')
...
ps_setup_reload_saved()
ps_setup_save()
GET_LOCK()
ps_setup_save()
ps_setup_save()
ps_setup_reload_saved()
ps_setup_save()
ps_setup_save()
ps_setup_save()
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
mysql> CALL ps_setup_show_disabled(TRUE, TRUE); +----------------------------+ | performance_schema_enabled | +----------------------------+ | 1 | +----------------------------+ +---------------+ | enabled_users | +---------------+ | '%'@'%' | +---------------+ +-------------+----------------------+---------+-------+ | object_type | objects | enabled | timed | +-------------+----------------------+---------+-------+ | EVENT | mysql.% | NO | NO | | EVENT | performance_schema.% | NO | NO | | EVENT | information_schema.% | NO | NO | | FUNCTION | mysql.% | NO | NO | | FUNCTION | performance_schema.% | NO | NO | | FUNCTION | information_schema.% | NO | NO | | PROCEDURE | mysql.% | NO | NO | | PROCEDURE | performance_schema.% | NO | NO | | PROCEDURE | information_schema.% | NO | NO | | TABLE | mysql.% | NO | NO | | TABLE | performance_schema.% | NO | NO | | TABLE | information_schema.% | NO | NO | | TRIGGER | mysql.% | NO | NO | | TRIGGER | performance_schema.% | NO | NO | | TRIGGER | information_schema.% | NO | NO | +-------------+----------------------+---------+-------+ ...
mysql> CALL ps_setup_show_disabled_consumers();
+----------------------------------+
| disabled_consumers |
+----------------------------------+
| events_stages_current |
| events_stages_history |
| events_stages_history_long |
| events_statements_history |
| events_statements_history_long |
| events_transactions_history |
| events_transactions_history_long |
| events_waits_current |
| events_waits_history |
| events_waits_history_long |
+----------------------------------+
mysql> CALL ps_setup_show_disabled_instruments()\G
*************************** 1. row ***************************
disabled_instruments: wait/synch/mutex/sql/TC_LOG_MMAP::LOCK_tc
timed: NO
*************************** 2. row ***************************
disabled_instruments: wait/synch/mutex/sql/THD::LOCK_query_plan
timed: NO
*************************** 3. row ***************************
disabled_instruments: wait/synch/mutex/sql/MYSQL_BIN_LOG::LOCK_commit
timed: NO
...
mysql> CALL ps_setup_show_enabled(FALSE, FALSE);
+----------------------------+
| performance_schema_enabled |
+----------------------------+
| 1 |
+----------------------------+
1 row in set (0.00 sec)
+---------------+
| enabled_users |
+---------------+
| '%'@'%' |
+---------------+
1 row in set (0.00 sec)
+-------------+----------------------+---------+-------+
| object_type | objects | enabled | timed |
+-------------+----------------------+---------+-------+
| EVENT | %.% | YES | YES |
| FUNCTION | %.% | YES | YES |
| PROCEDURE | %.% | YES | YES |
| TABLE | %.% | YES | YES |
| TRIGGER | %.% | YES | YES |
+-------------+----------------------+---------+-------+
5 rows in set (0.01 sec)
+-----------------------------+
| enabled_consumers |
+-----------------------------+
| events_statements_current |
| events_transactions_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+-----------------------------+
mysql> CALL ps_setup_show_enabled_consumers();
+-----------------------------+
| enabled_consumers |
+-----------------------------+
| events_statements_current |
| events_transactions_current |
| global_instrumentation |
| thread_instrumentation |
| statements_digest |
+-----------------------------+
mysql> CALL ps_setup_show_enabled_instruments()\G
*************************** 1. row ***************************
enabled_instruments: wait/io/file/sql/map
timed: YES
*************************** 2. row ***************************
enabled_instruments: wait/io/file/sql/binlog
timed: YES
*************************** 3. row ***************************
enabled_instruments: wait/io/file/sql/binlog_cache
timed: YES
...
events_statements_summary_by_digest
* = 2 units
mysql> CALL ps_statement_avg_latency_histogram()\G
*************************** 1. row ***************************
Performance Schema Statement Digest Average Latency Histogram:
. = 1 unit
* = 2 units
# = 3 units
(0 - 66ms) 88 | #############################
(66 - 133ms) 14 | ..............
(133 - 199ms) 4 | ....
(199 - 265ms) 5 | **
(265 - 332ms) 1 | .
(332 - 398ms) 0 |
(398 - 464ms) 1 | .
(464 - 531ms) 0 |
(531 - 597ms) 0 |
(597 - 663ms) 0 |
(663 - 730ms) 0 |
(730 - 796ms) 0 |
(796 - 863ms) 0 |
(863 - 929ms) 0 |
(929 - 995ms) 0 |
(995 - 1062ms) 0 |
Total Statements: 114; Buckets: 16; Bucket Size: 66 ms;
events_statements_summary_by_digest
EXPLAIN
EXPLAIN
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
in_digest VARCHAR(32)
in_runtime INT
in_interval DECIMAL(2,2)
in_start_fresh BOOLEAN
events_statements_history_long
events_stages_history_long
in_auto_enable BOOLEAN
mysql> CALL ps_trace_statement_digest('891ec6860f98ba46d89dd20b0c03652c', 10, 0.1, TRUE, TRUE);
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
| SUMMARY STATISTICS |
+--------------------+
1 row in set (9.11 sec)
+------------+-----------+-----------+-----------+---------------+------------+------------+
| executions | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scans |
+------------+-----------+-----------+-----------+---------------+------------+------------+
| 21 | 4.11 ms | 2.00 ms | 0 | 21 | 0 | 0 |
+------------+-----------+-----------+-----------+---------------+------------+------------+
1 row in set (9.11 sec)
+------------------------------------------+-------+-----------+
| event_name | count | latency |
+------------------------------------------+-------+-----------+
| stage/sql/statistics | 16 | 546.92 us |
| stage/sql/freeing items | 18 | 520.11 us |
| stage/sql/init | 51 | 466.80 us |
...
| stage/sql/cleaning up | 18 | 11.92 us |
| stage/sql/executing | 16 | 6.95 us |
+------------------------------------------+-------+-----------+
17 rows in set (9.12 sec)
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
| LONGEST RUNNING STATEMENT |
+---------------------------+
1 row in set (9.16 sec)
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| thread_id | exec_time | lock_time | rows_sent | rows_examined | tmp_tables | full_scan |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
| 166646 | 618.43 us | 1.00 ms | 0 | 1 | 0 | 0 |
+-----------+-----------+-----------+-----------+---------------+------------+-----------+
1 row in set (9.16 sec)
# Truncated for clarity...
+-----------------------------------------------------------------+
| sql_text |
+-----------------------------------------------------------------+
| select hibeventhe0_.id as id1382_, hibeventhe0_.createdTime ... |
+-----------------------------------------------------------------+
1 row in set (9.17 sec)
+------------------------------------------+-----------+
| event_name | latency |
+------------------------------------------+-----------+
| stage/sql/init | 8.61 us |
| stage/sql/init | 331.07 ns |
...
| stage/sql/freeing items | 30.46 us |
| stage/sql/cleaning up | 662.13 ns |
+------------------------------------------+-----------+
18 rows in set (9.23 sec)
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
| 1 | SIMPLE | hibeventhe0_ | const | fixedTime | fixedTime | 775 | const,const | 1 | NULL |
+----+-------------+--------------+-------+---------------+-----------+---------+-------------+------+-------+
1 row in set (9.27 sec)
Query OK, 0 rows affected (9.28 sec)
.dot
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
in_thread_id INT
in_outfile VARCHAR(255)
in_max_runtime DECIMAL(20,2)
in_interval DECIMAL(20,2)
in_start_fresh BOOLEAN
in_auto_setup BOOLEAN
in_debug BOOLEAN
mysql> CALL ps_trace_thread(25, CONCAT('/tmp/stack-', REPLACE(NOW(), ' ', '-'), '.dot'), NULL, NULL, TRUE, TRUE, TRUE);
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.00 sec)
+---------------------------------------------+
| Info |
+---------------------------------------------+
| Data collection starting for THREAD_ID = 25 |
+---------------------------------------------+
1 row in set (0.03 sec)
+-----------------------------------------------------------+
| Info |
+-----------------------------------------------------------+
| Stack trace written to /tmp/stack-2014-02-16-21:18:41.dot |
+-----------------------------------------------------------+
1 row in set (60.07 sec)
+-------------------------------------------------------------------+
| Convert to PDF |
+-------------------------------------------------------------------+
| dot -Tpdf -o /tmp/stack_25.pdf /tmp/stack-2014-02-16-21:18:41.dot |
+-------------------------------------------------------------------+
1 row in set (60.07 sec)
+-------------------------------------------------------------------+
| Convert to PNG |
+-------------------------------------------------------------------+
| dot -Tpng -o /tmp/stack_25.png /tmp/stack-2014-02-16-21:18:41.dot |
+-------------------------------------------------------------------+
1 row in set (60.07 sec)
+------------------+
| summary |
+------------------+
| Enabled 1 thread |
+------------------+
1 row in set (60.32 sec)
SYSTEM_VARIABLES_ADMIN
SUPER
sql_log_bin
in_action ENUM('snapshot', 'overall', 'delta',
'create_tmp', 'create_table', 'save',
'cleanup')
snapshot
events_statements_summary_by_digest
sys
overall
in_table
NOW()
in_table
NULL
statement_performance_analyzer.limit
delta
sys
in_views
create_table
create_tmp
save
cleanup
in_table VARCHAR(129)
db_name.tbl_name
tbl_name
.
in_table
in_action
in_views SET
('with_runtimes_in_95th_percentile', 'analysis',
'with_errors_or_warnings', 'with_full_table_scans',
'with_sorting', 'with_temp_tables', 'custom')
custom
with_runtimes_in_95th_percentile
statements_with_runtimes_in_95th_percentile
analysis
statement_analysis
with_errors_or_warnings
statements_with_errors_or_warnings
with_full_table_scans
statements_with_full_table_scans
with_sorting
statements_with_sorting
with_temp_tables
statements_with_temp_tables
custom
statement_performance_analyzer()
debug
ON
statement_performance_analyzer.limit
statement_performance_analyzer.view
events_statements_summary_by_digest
statement_performance_analyzer.limit
NULL
events_statements_summary_by_digest
mysql>CALL statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL);
Query OK, 0 rows affected (0.08 sec) mysql>CALL statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.02 sec) mysql>CALL statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL);
Query OK, 0 rows affected (0.00 sec) mysql>DO SLEEP(60);
Query OK, 0 rows affected (1 min 0.00 sec) mysql>CALL statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.02 sec) mysql>CALL statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile');
+-----------------------------------------+ | Next Output | +-----------------------------------------+ | Queries with Runtime in 95th Percentile | +-----------------------------------------+ 1 row in set (0.05 sec) ... mysql>CALL statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile');
+-----------------------------------------+ | Next Output | +-----------------------------------------+ | Queries with Runtime in 95th Percentile | +-----------------------------------------+ 1 row in set (0.03 sec) ...
mysql>CALL statement_performance_analyzer('snapshot', NULL, NULL);
Query OK, 0 rows affected (0.01 sec) mysql>SET @sys.statement_performance_analyzer.limit = 10;
Query OK, 0 rows affected (0.00 sec) mysql>CALL statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans');
+-----------------------------------------+ | Next Output | +-----------------------------------------+ | Queries with Runtime in 95th Percentile | +-----------------------------------------+ 1 row in set (0.01 sec) ... +-------------------------------------+ | Next Output | +-------------------------------------+ | Top 10 Queries with Full Table Scan | +-------------------------------------+ 1 row in set (0.09 sec) ...
mysql>CREATE OR REPLACE VIEW mydb.my_statements AS
->SELECT sys.format_statement(DIGEST_TEXT) AS query,
->SCHEMA_NAME AS db,
->COUNT_STAR AS exec_count,
->sys.format_time(SUM_TIMER_WAIT) AS total_latency,
->sys.format_time(AVG_TIMER_WAIT) AS avg_latency,
->ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
->ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
->ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg,
->DIGEST AS digest
->FROM performance_schema.events_statements_summary_by_digest
->ORDER BY SUM_TIMER_WAIT DESC;
Query OK, 0 rows affected (0.01 sec) mysql>CALL statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);
Query OK, 0 rows affected (0.10 sec) shell>watch -n 60 "mysql sys --table -e \"
>SET @sys.statement_performance_analyzer.view = 'mydb.my_statements';
>SET @sys.statement_performance_analyzer.limit = 10;
>CALL statement_performance_analyzer('snapshot', NULL, NULL);
>CALL statement_performance_analyzer('delta', 'mydb.digests_prev', 'custom');
>CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL);
>\""
Every 60.0s: mysql sys --table -e " ... Mon Dec 22 10:58:51 2014 +----------------------------------+ | Next Output | +----------------------------------+ | Top 10 Queries Using Custom View | +----------------------------------+ +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+ | query | db | exec_count | total_latency | avg_latency | rows_sent_avg | rows_examined_avg | rows_affected_avg | digest | +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+ ...
TEMPORARY
TEMPORARY
in_db VARCHAR(64)
in_table VARCHAR(64)
out_exists ENUM('', 'BASE TABLE', 'VIEW',
'TEMPORARY')
''
BASE TABLE
VIEW
TEMPORARY
mysql>CREATE DATABASE db1;
Query OK, 1 row affected (0.01 sec) mysql>USE db1;
Database changed mysql>CREATE TABLE t1 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.03 sec) mysql>CREATE TABLE t2 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.20 sec) mysql>CREATE view v_t1 AS SELECT * FROM t1;
Query OK, 0 rows affected (0.02 sec) mysql>CREATE TEMPORARY TABLE t1 (id INT PRIMARY KEY);
Query OK, 0 rows affected (0.00 sec) mysql>CALL sys.table_exists('db1', 't1', @exists); SELECT @exists;
Query OK, 0 rows affected (0.01 sec) +-----------+ | @exists | +-----------+ | TEMPORARY | +-----------+ 1 row in set (0.00 sec) mysql>CALL sys.table_exists('db1', 't2', @exists); SELECT @exists;
Query OK, 0 rows affected (0.02 sec) +------------+ | @exists | +------------+ | BASE TABLE | +------------+ 1 row in set (0.00 sec) mysql>CALL sys.table_exists('db1', 'v_t1', @exists); SELECT @exists;
Query OK, 0 rows affected (0.02 sec) +---------+ | @exists | +---------+ | VIEW | +---------+ 1 row in set (0.00 sec) mysql>CALL sys.table_exists('db1', 't3', @exists); SELECT @exists;
Query OK, 0 rows affected (0.00 sec) +---------+ | @exists | +---------+ | | +---------+ 1 row in set (0.00 sec)
sys
DATA_DIRECTORY
mysql> SELECT extract_schema_from_file_name('/usr/local/mysql/data/world/City.ibd');
+-----------------------------------------------------------------------+
| extract_schema_from_file_name('/usr/local/mysql/data/world/City.ibd') |
+-----------------------------------------------------------------------+
| world |
+-----------------------------------------------------------------------+
mysql> SELECT extract_table_from_file_name('/usr/local/mysql/data/world/City.ibd');
+----------------------------------------------------------------------+
| extract_table_from_file_name('/usr/local/mysql/data/world/City.ibd') |
+----------------------------------------------------------------------+
| City |
+----------------------------------------------------------------------+
bytes
MiB
TiB
mysql> SELECT format_bytes(512), format_bytes(18446644073709551615);
+-------------------+------------------------------------+
| format_bytes(512) | format_bytes(18446644073709551615) |
+-------------------+------------------------------------+
| 512 bytes | 16383.91 PiB |
+-------------------+------------------------------------+
datadir tmpdir slave_load_tmpdir innodb_data_home_dir innodb_log_group_home_dir innodb_undo_directory basedir
sysvar
sysvar
mysql> SELECT format_path('/usr/local/mysql/data/world/City.ibd');
+-----------------------------------------------------+
| format_path('/usr/local/mysql/data/world/City.ibd') |
+-----------------------------------------------------+
| @@datadir/world/City.ibd |
+-----------------------------------------------------+
statement_truncate_len
...
format_statement()
statement_truncate_len
format_statement()
format_statement()
mysql>SET @stmt = 'SELECT variable, value, set_time, set_by FROM sys_config';
mysql>SELECT format_statement(@stmt);
+----------------------------------------------------------+ | format_statement(@stmt) | +----------------------------------------------------------+ | SELECT variable, value, set_time, set_by FROM sys_config | +----------------------------------------------------------+ mysql>SET @sys.statement_truncate_len = 32;
mysql>SELECT format_statement(@stmt);
+-----------------------------------+ | format_statement(@stmt) | +-----------------------------------+ | SELECT variabl ... ROM sys_config | +-----------------------------------+
ns
ms
m
d
list_drop()
sql_mode
optimizer_switch
mysql>SELECT @@sql_mode;
+----------------------------------------+ | @@sql_mode | +----------------------------------------+ | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES | +----------------------------------------+ mysql>SET @@sql_mode = list_add(@@sql_mode, 'NO_ENGINE_SUBSTITUTION');
mysql>SELECT @@sql_mode;
+---------------------------------------------------------------+ | @@sql_mode | +---------------------------------------------------------------+ | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | +---------------------------------------------------------------+ mysql>SET @@sql_mode = list_drop(@@sql_mode, 'ONLY_FULL_GROUP_BY');
mysql>SELECT @@sql_mode;
+--------------------------------------------+ | @@sql_mode | +--------------------------------------------+ | STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION | +--------------------------------------------+
YES
NULL
YES
mysql>SELECT ps_is_instrument_default_enabled('memory/innodb/row_log_buf');
+---------------------------------------------------------------+ | ps_is_instrument_default_enabled('memory/innodb/row_log_buf') | +---------------------------------------------------------------+ | NO | +---------------------------------------------------------------+ mysql>SELECT ps_is_instrument_default_enabled('statement/sql/alter_user');
+--------------------------------------------------------------+ | ps_is_instrument_default_enabled('statement/sql/alter_user') | +--------------------------------------------------------------+ | YES | +--------------------------------------------------------------+
YES
mysql>SELECT ps_is_instrument_default_timed('memory/innodb/row_log_buf');
+-------------------------------------------------------------+ | ps_is_instrument_default_timed('memory/innodb/row_log_buf') | +-------------------------------------------------------------+ | NO | +-------------------------------------------------------------+ mysql>SELECT ps_is_instrument_default_timed('statement/sql/alter_user');
+------------------------------------------------------------+ | ps_is_instrument_default_timed('statement/sql/alter_user') | +------------------------------------------------------------+ | YES | +------------------------------------------------------------+
YES
UNKNOWN
NULL
in_connection_id BIGINT UNSIGNED
threads
SHOW PROCESSLIST
mysql>SELECT ps_is_thread_instrumented(43);
+-------------------------------+ | ps_is_thread_instrumented(43) | +-------------------------------+ | UNKNOWN | +-------------------------------+ mysql>SELECT ps_is_thread_instrumented(CONNECTION_ID());
+--------------------------------------------+ | ps_is_thread_instrumented(CONNECTION_ID()) | +--------------------------------------------+ | YES | +--------------------------------------------+
user_name
@host_name
in_thread_id BIGINT UNSIGNED
threads
NULL
in_connection_id BIGINT UNSIGNED
threads
SHOW PROCESSLIST
in_thread_id BIGINT
threads
in_verbose BOOLEAN
mysql> SELECT ps_thread_stack(37, FALSE) AS thread_stack\G
*************************** 1. row ***************************
thread_stack: {"rankdir": "LR","nodesep": "0.10",
"stack_created": "2014-02-19 13:39:03", "mysql_version": "8.0.2-dmr-debug-log",
"mysql_user": "root@localhost","events": [{"nesting_event_id": "0",
"event_id": "10", "timer_wait": 256.35, "event_info": "sql/select",
"wait_info": "select @@version_comment limit 1\nerrors: 0\nwarnings: 0\nlock time:
...
events_transactions_current
events_statements_history
{ "error": "Trx info truncated: Row 6 was cut by GROUP_CONCAT()" }
in_thread_id BIGINT UNSIGNED
threads
ps_thread_trx_info()
ps_thread_trx_info.max_length
mysql> SELECT ps_thread_trx_info(48)\G
*************************** 1. row ***************************
ps_thread_trx_info(48): [
{
"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
},
{
"sql_text": "COMMIT",
"time": "254.42 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
},
{
"time": "426.20 us",
"state": "COMMITTED",
"mode": "READ WRITE",
"autocommitted": "NO",
"gtid": "AUTOMATIC",
"isolation": "REPEATABLE READ",
"statements_executed": [
{
"sql_text": "INSERT INTO info VALUES (2, \'bar\')",
"time": "107.33 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
},
{
"sql_text": "COMMIT",
"time": "213.23 us",
"schema": "trx",
"rows_examined": 0,
"rows_affected": 0,
"rows_sent": 0,
"tmp_tables": 0,
"tmp_disk_tables": 0,
"sort_rows": 0,
"sort_merge_passes": 0
}
]
}
]
`
mysql>SELECT quote_identifier('plain');
+---------------------------+ | quote_identifier('plain') | +---------------------------+ | `plain` | +---------------------------+ mysql>SELECT quote_identifier('trick`ier');
+-------------------------------+ | quote_identifier('trick`ier') | +-------------------------------+ | `trick``ier` | +-------------------------------+ mysql>SELECT quote_identifier('integer');
+-----------------------------+ | quote_identifier('integer') | +-----------------------------+ | `integer` | +-----------------------------+
sys_config
sys_get_config()
NULL
sys_get_config()
sys_config
sys_get_config()
IFNULL(...)
in_variable_name VARCHAR(128)
in_default_value VARCHAR(128)
sys_config
MySQL的> SELECT sys.sys_get_config('statement_truncate_len', 128) AS Value;
------- |价值| ------- | 64 | -------
IFNULL(...)
sys_config
MySQL的> SET @sys.statement_truncate_len =
-> IFNULL(@sys.statement_truncate_len,
-> sys.sys_get_config('statement_truncate_len', 64));
IF (...) THEN ... END IF;
sys_config
IF (@sys.statement_truncate_len IS NULL) THEN SET @sys.statement_truncate_len = sys.sys_get_config('statement_truncate_len', 64);END IF;