Performance Schema provides low-level metrics on operations running inside MySQL Server.
performance_schema.setup_instruments
table contains instruments and their statusperformance_schema.setup_consumers
table contains consumers and their statusIn order to find out which statements require optimiztion, we can execute below query
SHOW CREATE TABLE performance_schema.event_statement_history
Important columns are like:
CREATED_TMP_DISK_TABLES
CREATED_TMP_TABLES
SELECT_FULL_JOIN
SELECT_RANGE_CHECK
SORT_ROWS
RETURNED_ROWS
SORT_SCAN
NO_INDEX_USED
NO_GOOD_INDEX_USED
The statement holding meatadata lock is not listed on process list like
Waiting for a metadata lock
, if it is a part of multiple statements transaction
/wait/lock/metadata/sql/mdl
metadata_locks
SELECT * FROM metadata_locks JOIN threads ON (owner_thread_id=thread_id);
Memory usage can be examined by enabling memory
instrument,
and statistics for them is provided by tables named memory_summary
prefix
SELECT EVENT_NAME, CURRENT_NUMBER_OF_BYES_USED/1024/1024 AS CURRENT_MB,
HIGH_NUMBER_OF_BYTES_USED/1024/1024 AS HIGH_MB,
FROM performance_schema.memory_summary_global_by_event_name
WHERE EVENT_NAME LIKE 'memory/innodb/%'
ORDER BY CURRENT_MB DESC;
It consists only of views and stored routines over performance_schema
Find problematic statements (Digest Query)
statements_with_full_table_scans
statements_with_erros_or_warnings
statements_with_temp_tables
Provides memory statistics in a better way aggregated by host, user, thread, global
memory_global_total
memory_by_thread_by_current_bytes