What is MySQL's performance schema?
Answer
The Performance Schema (P_S) is a built-in MySQL database (performance_schema) that provides a low-level monitoring capability for MySQL server execution. It instruments server internals to collect performance data with minimal overhead. Enabled by default in MySQL 5.6+. Key tables: events_statements_* — SQL statement statistics (total time, rows examined, temporary tables); events_stages_* — internal processing stages per statement; events_waits_* — wait events (mutex waits, I/O waits, lock waits); table_io_waits_summary_by_table — I/O activity per table; table_lock_waits_summary_by_table — lock waits per table; file_summary_by_event_name — file I/O. Useful queries: find top slow queries: SELECT DIGEST_TEXT, AVG_TIMER_WAIT/1e12 AS avg_sec, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY avg_sec DESC LIMIT 10;. The sys schema (MySQL 5.7.7+) provides user-friendly views on top of performance_schema: SELECT * FROM sys.statements_with_full_table_scans ORDER BY no_index_used_count DESC;. Enable specific instruments: UPDATE performance_schema.setup_instruments SET ENABLED="YES" WHERE NAME LIKE "statement/%";
Previous
What is event scheduling in MySQL?
Next
What is ProxySQL and how does it help MySQL deployments?
More MySQL / SQL Questions
View all →- Advanced What is the difference between B-tree and Hash indexes in MySQL?
- Advanced What is MVCC (Multi-Version Concurrency Control) in MySQL?
- Advanced What is the InnoDB Buffer Pool and how does it work?
- Advanced What is deadlock in MySQL and how do you prevent it?
- Advanced What is the query execution plan and how does the MySQL optimizer work?