show processlist; show full processlist; select * from information_schema.processlist;
其中,show processlist爲簡要查看當前鏈接數據庫狀況,包含SQL語句的statement列僅提供部分SQL,而show full processlist則提供完整的SQL 語句,information_schema.processlist的內容與show full processlist 內容一致,可是能夠以表格查詢的形式添加where條件,達到本身的使用需求。linux
select * from sys.processlist; select * from sys.session; select * from sys.x$processlist; select * from sys.x$session;
select table_schema,table_name,sum(io_read_requests+io_write_requests) io from schema_table_statistics group by table_schema,table_name order by io desc limit 10; +--------------+----------------------------------+------+ | table_schema | table_name | io | +--------------+----------------------------------+------+ | ycf_sqlpub | django_session | 2194 | | dba_sqlpub | django_session | 735 | | ycf_sqlpub | sqlversion_registersql | 347 | | ycf_sqlpub | xadmin_log | 331 | | ycf_sqlpub | sqlversion_registersqllog_sqls | 329 | | ycf_sqlpub | sqlversion_sqlpublishlog_version | 311 | | ycf_sqlpub | sqlversion_sqlpublishlog | 308 | | ycf_sqlpub | sqlversion_registersqllog | 299 | | ycf_sqlpub | auth_group_permissions | 298 | | ycf_sqlpub | testenv_testalldb | 295 | +--------------+----------------------------------+------+
# 冗餘索引查看 select table_schema,table_name,redundant_index_name,redundant_index_columns,dominant_index_name,dominant_index_columns from sys.schema_redundant_indexes; # 未使用索引查看 select * from schema_unused_indexes;
select * from schema_auto_increment_columns \G
select * from sys.statements_with_full_table_scans where db = 'test';
select file,avg_read+avg_write as avg_io from io_global_by_file_by_bytes order by avg_io desc limit 10;