巡检人:小麦苗 QQ:646634621 微信公众号:DB宝 提供OCP、OCM、高可用(rac+dg)、PostgreSQL和MySQL培训 BLOG地址: https://www.dbaup.com 若需要脚本可私聊我
万里GreatDB数据库巡检报告

Copyright (c) 2015-2100 (https://www.dbaup.com) lhrbest. All rights reserved.

巡 检 人:小麦苗([QQ:646634621] [微信公众号:DB宝] [提供OCP、OCM、高可用、MySQL和PostgreSQL最实用的培训])
巡检时间:2022-04-08 11:19:32
版 本 号:v7.0.0
修改日期:2022-4-8 18:28:00

[转到页底]


目录
总体概况 数据库基本信息数据库的总体概况、版本、主机情况、数据库负载情况、数据库属性等 所有数据库及其容量大小当前数据库实例的所有数据库及其容量大小 查看数据库的运行状态 占用空间最大的前10张大表 所有存储引擎列表当前数据库实例的所有存储引擎列表
存储引擎和DB的数量关系 查询所有用户 查询MySQL支持的所有字符集 一些重要的参数
锁情况 查询所有线程排除sleep线程 sleep线程TOP20 有多少线程正在使用表 InnoDB存储引擎的运行时信息查询InnoDB存储引擎的运行时信息,包括死锁的详细信息 元数据锁的相关信息
SQL部分 跟踪长时间操作的进度 平均执行时间值大于95%的平均执行时间的语句查看平均执行时间值大于95%的平均执行时间的语句(可近似地认为是平均执行时间超长的语句),默认情况下按照语句平均延迟(执行时间)降序排序 使用了临时表的语句查看使用了临时表的语句,默认情况下按照磁盘临时表数量和内存临时表数量进行降序排序 查看执行了文件排序的语句默认情况下按照语句总延迟时间(执行时间)降序排序 查询SQL的整体消耗百分比
执行次数Top10 使用全表扫描的SQL语句使用全表扫描的SQL语句 没有使用到最优索引的语句查看全表扫描或者没有使用到最优索引的语句(经过标准化转化的语句文本),默认情况下按照全表扫描次数与语句总次数百分比和语句总延迟时间(执行时间)降序排序 产生错误或警告的语句查看产生错误或警告的语句,默认情况下,按照错误数量和警告数量降序排序
索引部分 冗余索引 无效索引(从未使用过的索引) 索引区分度区分度,越接近1,表示区分度越高,低于0.1,则说明区分度较差,开发者应该重新评估SQL语句涉及的字段,选择区分度高的多个字段创建索引
主从情况 MySQL Replication(MySQL主从复制) 主从复制涉及到的重要参数 主从库线程主从库线程查询 二进制日志 主库状态监测 备库状态监测
数据库性能 性能参数统计
其它 setup_consumers 自增ID的使用 无主键或唯一键的表



数据库总体概况

● 数据库基本信息
now_dateuserCURRENT_USER1CONNECTION_IDdb_nameServer_versionall_db_size_MBall_datafile_size_MBdatadirSOCKETlog_errorautocommitlog_binserver_id
2022-04-08 11:19:38root@192.168.66.64root@%158.0.25-157.6186.00/data/GreatSQL//data/GreatSQL/mysql.sock/data/GreatSQL/error.log113306

● 版本信息

● 插件信息
PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_STATUSPLUGIN_TYPEPLUGIN_TYPE_VERSIONPLUGIN_LIBRARYPLUGIN_LIBRARY_VERSIONPLUGIN_AUTHORPLUGIN_DESCRIPTIONPLUGIN_LICENSELOAD_OPTION
binlog1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationThis is a pseudo storage engine to represent the binlog in a transactionGPLFORCE
mysql_native_password1.1ACTIVEAUTHENTICATION2.0Oracle CorporationNative MySQL authenticationGPLFORCE
sha256_password1.1ACTIVEAUTHENTICATION2.0Oracle CorporationSHA256 password authenticationGPLFORCE
caching_sha2_password1.0ACTIVEAUTHENTICATION2.0Oracle CorporationCaching sha2 authenticationGPLFORCE
sha2_cache_cleaner1.0ACTIVEAUDIT4.1Oracle CorporationCache cleaner for Caching sha2 authenticationGPLFORCE
daemon_keyring_proxy_plugin1.0ACTIVEDAEMON80025.0OracleA plugin that implements the keyring component services atop of the keyring pluginGPLFORCE
PERFORMANCE_SCHEMA0.1ACTIVESTORAGE ENGINE80025.0Oracle CorporationPerformance SchemaGPLFORCE
CSV1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationCSV storage engineGPLFORCE
MEMORY1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationHash based, stored in memory, useful for temporary tablesGPLFORCE
InnoDB8.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationPercona-XtraDB, Supports transactions, row-level locking, and foreign keysGPLFORCE
INNODB_TRX8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB transactionsGPLFORCE
INNODB_CMP8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compressionGPLFORCE
INNODB_CMP_RESET8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compression; reset cumulated countsGPLFORCE
INNODB_CMPMEM8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compressed buffer poolGPLFORCE
INNODB_CMPMEM_RESET8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compressed buffer pool; reset cumulated countsGPLFORCE
INNODB_CMP_PER_INDEX8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compression (per index)GPLFORCE
INNODB_CMP_PER_INDEX_RESET8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationStatistics for the InnoDB compression (per index); reset cumulated countsGPLFORCE
INNODB_BUFFER_PAGE8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Buffer Page InformationGPLFORCE
INNODB_BUFFER_PAGE_LRU8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Buffer Page in LRUGPLFORCE
INNODB_BUFFER_POOL_STATS8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Buffer Pool Statistics Information GPLFORCE
INNODB_TEMP_TABLE_INFO8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Temp Table StatsGPLFORCE
INNODB_METRICS8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Metrics InfoGPLFORCE
INNODB_FT_DEFAULT_STOPWORD8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationDefault stopword list for InnDB Full Text SearchGPLFORCE
INNODB_FT_DELETED8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationINNODB AUXILIARY FTS DELETED TABLEGPLFORCE
INNODB_FT_BEING_DELETED8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationINNODB AUXILIARY FTS BEING DELETED TABLEGPLFORCE
INNODB_FT_CONFIG8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationINNODB AUXILIARY FTS CONFIG TABLEGPLFORCE
INNODB_FT_INDEX_CACHE8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationINNODB AUXILIARY FTS INDEX CACHEDGPLFORCE
INNODB_FT_INDEX_TABLE8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationINNODB AUXILIARY FTS INDEX TABLEGPLFORCE
INNODB_TABLES8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_TABLESGPLFORCE
INNODB_TABLESTATS8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_TABLESTATSGPLFORCE
INNODB_INDEXES8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_INDEXESGPLFORCE
INNODB_TABLESPACES8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_TABLESPACESGPLFORCE
INNODB_COLUMNS8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_COLUMNSGPLFORCE
INNODB_VIRTUAL8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB INNODB_VIRTUALGPLFORCE
INNODB_CACHED_INDEXES8.2ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB cached indexesGPLFORCE
INNODB_SESSION_TEMP_TABLESPACES8.0ACTIVEINFORMATION SCHEMA80025.0Oracle CorporationInnoDB Session Temporary tablespacesGPLFORCE
INNODB_TABLESPACES_ENCRYPTION8.2ACTIVEINFORMATION SCHEMA80025.0Google IncInnoDB TABLESPACES_ENCRYPTIONBSDFORCE
INNODB_TABLESPACES_SCRUBBING8.0ACTIVEINFORMATION SCHEMA80025.0Google IncInnoDB TABLESPACES_SCRUBBINGBSDFORCE
INNODB_CHANGED_PAGES1.0ACTIVEINFORMATION SCHEMA80025.0PerconaInnoDB CHANGED_PAGES tableGPLFORCE
MyISAM1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationMyISAM storage engineGPLFORCE
MRG_MYISAM1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationCollection of identical MyISAM tablesGPLFORCE
TempTable1.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationInnoDB temporary storage engineGPLFORCE
ARCHIVE3.0ACTIVESTORAGE ENGINE80025.0Oracle CorporationArchive storage engineGPLON
BLACKHOLE1.0ACTIVESTORAGE ENGINE80025.0Oracle Corporation/dev/null storage engine (anything you write to it disappears)GPLON
FEDERATED1.0DISABLEDSTORAGE ENGINE80025.0Oracle CorporationFederated MySQL storage engineGPLOFF
ngram0.1ACTIVEFTPARSER1.1Oracle CorporationNgram Full-Text ParserGPLON
mysqlx_cache_cleaner1.0ACTIVEAUDIT4.1Oracle CorporationCache cleaner for sha2 authentication in X pluginGPLON
mysqlx1.0ACTIVEDAEMON80025.0Oracle CorporationX Plugin for MySQLGPLON
clone1.0ACTIVECLONE1.0mysql_clone.so1.10Oracle CorporationCLONE PLUGINGPLON
group_replication1.1ACTIVEGROUP REPLICATION1.4group_replication.so1.10Oracle CorporationGroup Replication (1.1.0)GPLON

● 当前数据库实例的所有数据库及其容量大小
SCHEMA_NAMEDEFAULT_CHARACTER_SET_NAMEDEFAULT_COLLATION_NAMEtable_rowsdata_size_mbindex_size_mball_size_mbmax_size_mbfree_size_mbdisk_size_mb
mysqlutf8mb4utf8mb4_0900_ai_ci1385507.430.317.750.00132.00
sysutf8mb4utf8mb4_0900_ai_ci60.010.000.010.000.000.00
information_schemautf8utf8_general_ci00.000.000.000.000.00
performance_schemautf8mb4utf8mb4_0900_ai_ci29646720.000.000.000.000.00

● 数据库对象
db_nameob_typesums
mysqlTABLE35
performance_schemaTABLE114
sysTABLE1
sysTRIGGERS2
sysPROCEDURE26
sysFUNCTION22
sysVIEWS100

● 查看数据库的运行状态
-------------- mysql Ver 14.14 Distrib 5.7.30, for Win64 (x86_64) Connection id: 15 Current database: Current user: root@192.168.66.64 SSL: Cipher in use is ECDHE-RSA-AES128-GCM-SHA256 Using delimiter: ; Server version: 8.0.25-15 GreatSQL, Release 15, Revision c7feae175e0 Protocol version: 10 Connection: 192.168.66.35 via TCP/IP Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 26 min 15 sec Threads: 2 Questions: 3801 Slow queries: 9 Opens: 1736 Flush tables: 3 Open tables: 297 Queries per second avg: 2.413 --------------

● 占用空间最大的前10张大表
db_nametable_nameTABLE_TYPEENGINECREATE_TIMEUPDATE_TIMETABLE_COLLATIONtable_rowstb_size_mbindex_size_mball_size_mbfree_size_mbdisk_size_mb
mysqltime_zone_transitionBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci1208384.510.004.514.00
mysqlhelp_topicBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci4621.510.091.604.00
mysqltime_zone_transition_typeBASE TABLEInnoDB2022-04-08 10:52:50utf8_general_ci97770.420.000.424.00
mysqlhelp_keywordBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci10050.120.120.254.00
mysqltime_zone_nameBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci18640.230.000.234.00
mysqlhelp_relationBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci26310.090.000.094.00
mysqltime_zoneBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci18120.070.000.074.00
mysqlglobal_grantsBASE TABLEInnoDB2022-04-08 10:52:49utf8_bin700.060.000.064.00
mysqltables_privBASE TABLEInnoDB2022-04-08 10:52:49utf8_bin20.010.010.034.00
mysqlhelp_categoryBASE TABLEInnoDB2022-04-08 10:52:49utf8_general_ci530.010.010.034.00

● 占用空间最大的前10个索引
database_nametable_nameindex_nameSizeMBNON_UNIQUEINDEX_TYPECOLUMN_NAME

● 所有存储引擎列表
ENGINESUPPORTCOMMENTTRANSACTIONSXASAVEPOINTS
FEDERATEDNOFederated MySQL storage engine
PERFORMANCE_SCHEMAYESPerformance SchemaNONONO
InnoDBDEFAULTPercona-XtraDB, Supports transactions, row-level locking, and foreign keysYESYESYES
MEMORYYESHash based, stored in memory, useful for temporary tablesNONONO
MyISAMYESMyISAM storage engineNONONO
MRG_MYISAMYESCollection of identical MyISAM tablesNONONO
BLACKHOLEYES/dev/null storage engine (anything you write to it disappears)NONONO
CSVYESCSV storage engineNONONO
ARCHIVEYESArchive storage engineNONONO

● 存储引擎和DB的数量关系
ENGINEcounts
191
InnoDB34
CSV2
PERFORMANCE_SCHEMA114

TABLE_SCHEMAENGINEcounts
information_schema91
mysqlCSV2
mysqlInnoDB33
performance_schemaPERFORMANCE_SCHEMA114
sys100
sysInnoDB1

● InnoDB 系统表空间
FILE_IDFILE_NAMEFILE_TYPETABLESPACE_NAMETABLE_CATALOGTABLE_SCHEMATABLE_NAMELOGFILE_GROUP_NAMELOGFILE_GROUP_NUMBERENGINEFULLTEXT_KEYSDELETED_ROWSUPDATE_COUNTFREE_EXTENTSTOTAL_EXTENTSEXTENT_SIZEINITIAL_SIZEMAXIMUM_SIZEAUTOEXTEND_SIZECREATION_TIMELAST_UPDATE_TIMELAST_ACCESS_TIMERECOVER_TIMETRANSACTION_COUNTERVERSIONROW_FORMATTABLE_ROWSAVG_ROW_LENGTHDATA_LENGTHMAX_DATA_LENGTHINDEX_LENGTHDATA_FREECREATE_TIMEUPDATE_TIMECHECK_TIMECHECKSUMSTATUSEXTRA
0./ibdata1TABLESPACEinnodb_systemInnoDB212104857612582912671088646291456NORMAL
4294967293./ibtmp1TEMPORARYinnodb_temporaryInnoDB212104857612582912671088646291456NORMAL
4294967279./undo_001UNDO LOGinnodb_undo_001InnoDB416104857616777216167772168388608NORMAL
4294967278./undo_002UNDO LOGinnodb_undo_002InnoDB016104857616777216167772168388608NORMAL

● 查询所有用户
HostUserSelect_privInsert_privUpdate_privDelete_privCreate_privDrop_privReload_privShutdown_privProcess_privFile_privGrant_privReferences_privIndex_privAlter_privShow_db_privSuper_privCreate_tmp_table_privLock_tables_privExecute_privRepl_slave_privRepl_client_privCreate_view_privShow_view_privCreate_routine_privAlter_routine_privCreate_user_privEvent_privTrigger_privCreate_tablespace_privssl_typessl_cipherx509_issuerx509_subjectmax_questionsmax_updatesmax_connectionsmax_user_connectionsplugin
%replNNNNNNNNNNNNNNNNNNNYNNNNNNNNN0000mysql_native_password
%rootYYYYYYYYYYYYYYYYYYYYYYYYYYYYY0000caching_sha2_password
localhostmysql.infoschemaYNNNNNNNNNNNNNNNNNNNNNNNNNNNN0000caching_sha2_password
localhostmysql.sessionNNNNNNNYNNNNNNNYNNNNNNNNNNNNN0000caching_sha2_password
localhostmysql.sysNNNNNNNNNNNNNNNNNNNNNNNNNNNNN0000caching_sha2_password
localhostrootYYYYYYYYYYYYYYYYYYYYYYYYYYYYY0000caching_sha2_password

● 查询MySQL支持的所有字符集
CHARACTER_SET_NAMEDEFAULT_COLLATE_NAMEDESCRIPTIONMAXLEN
big5big5_chinese_ciBig5 Traditional Chinese2
dec8dec8_swedish_ciDEC West European1
cp850cp850_general_ciDOS West European1
hp8hp8_english_ciHP West European1
koi8rkoi8r_general_ciKOI8-R Relcom Russian1
latin1latin1_swedish_cicp1252 West European1
latin2latin2_general_ciISO 8859-2 Central European1
swe7swe7_swedish_ci7bit Swedish1
asciiascii_general_ciUS ASCII1
ujisujis_japanese_ciEUC-JP Japanese3
sjissjis_japanese_ciShift-JIS Japanese2
hebrewhebrew_general_ciISO 8859-8 Hebrew1
tis620tis620_thai_ciTIS620 Thai1
euckreuckr_korean_ciEUC-KR Korean2
koi8ukoi8u_general_ciKOI8-U Ukrainian1
gb2312gb2312_chinese_ciGB2312 Simplified Chinese2
greekgreek_general_ciISO 8859-7 Greek1
cp1250cp1250_general_ciWindows Central European1
gbkgbk_chinese_ciGBK Simplified Chinese2
latin5latin5_turkish_ciISO 8859-9 Turkish1
armscii8armscii8_general_ciARMSCII-8 Armenian1
utf8utf8_general_ciUTF-8 Unicode3
ucs2ucs2_general_ciUCS-2 Unicode2
cp866cp866_general_ciDOS Russian1
keybcs2keybcs2_general_ciDOS Kamenicky Czech-Slovak1
maccemacce_general_ciMac Central European1
macromanmacroman_general_ciMac West European1
cp852cp852_general_ciDOS Central European1
latin7latin7_general_ciISO 8859-13 Baltic1
cp1251cp1251_general_ciWindows Cyrillic1
utf16utf16_general_ciUTF-16 Unicode4
utf16leutf16le_general_ciUTF-16LE Unicode4
cp1256cp1256_general_ciWindows Arabic1
cp1257cp1257_general_ciWindows Baltic1
utf32utf32_general_ciUTF-32 Unicode4
binarybinaryBinary pseudo charset1
geostd8geostd8_general_ciGEOSTD8 Georgian1
cp932cp932_japanese_ciSJIS for Windows Japanese2
eucjpmseucjpms_japanese_ciUJIS for Windows Japanese3
gb18030gb18030_chinese_ciChina National Standard GB180304
utf8mb4utf8mb4_0900_ai_ciUTF-8 Unicode4

● 一些重要的参数

● 查看当前连接到数据库的用户和Host
USERHOST
event_schedulerlocalhost
root192.168.66.64:7401

● 查看每个host的当前连接数和总连接数
HOSTCURRENT_CONNECTIONSTOTAL_CONNECTIONS
17
localhost11
192.168.66.6418

● 按照登录用户+登录服务器查看登录信息
login_userlogin_iplogin_count
event_scheduler1
root192.168.66.641

● 按照登录用户+数据库+登录服务器查看登录信息
database_namelogin_userlogin_iplogin_count
event_scheduler1
root192.168.66.641

[回到目录]


锁情况


● 查询所有线程(排除sleep线程)
IDUSERHOSTDBCOMMANDTIMESTATEINFO
5event_schedulerlocalhostDaemon1576Waiting on empty queue

THREAD_IDNAMETYPEPROCESSLIST_IDPROCESSLIST_USERPROCESSLIST_HOSTPROCESSLIST_DBPROCESSLIST_COMMANDPROCESSLIST_TIMEPROCESSLIST_STATEPROCESSLIST_INFOPARENT_THREAD_IDROLEINSTRUMENTEDHISTORYCONNECTION_TYPETHREAD_OS_ID
43thread/sql/event_schedulerFOREGROUND5event_schedulerlocalhostDaemon1576Waiting on empty queue1YESYES168
47thread/sql/compress_gtid_tableFOREGROUND7Daemon1576Suspending1YESYES172

● sleep线程TOP20
IDUSERHOSTDBCOMMANDTIMESTATEINFO

THREAD_IDNAMETYPEPROCESSLIST_IDPROCESSLIST_USERPROCESSLIST_HOSTPROCESSLIST_DBPROCESSLIST_COMMANDPROCESSLIST_TIMEPROCESSLIST_STATEPROCESSLIST_INFOPARENT_THREAD_IDROLEINSTRUMENTEDHISTORYCONNECTION_TYPETHREAD_OS_ID

● 有多少线程正在使用表

● 查询InnoDB存储引擎的运行时信息,包括死锁的详细信息

● 当前Innodb内核中的当前活跃(active)事务
trx_idtrx_statetrx_startedtrx_requested_lock_idtrx_wait_startedtrx_weighttrx_mysql_thread_idtrx_querytrx_operation_statetrx_tables_in_usetrx_tables_lockedtrx_lock_structstrx_lock_memory_bytestrx_rows_lockedtrx_rows_modifiedtrx_concurrency_ticketstrx_isolation_leveltrx_unique_checkstrx_foreign_key_checkstrx_last_foreign_key_errortrx_adaptive_hash_latchedtrx_adaptive_hash_timeouttrx_is_read_onlytrx_autocommit_non_locking

● 锁详情

● 元数据锁的相关信息
NAMEENABLEDTIMED
wait/lock/metadata/sql/mdlYESYES

locked_schemalocked_tablelocked_typewaiting_processlist_idwaiting_agewaiting_querywaiting_stateblocking_processlist_idblocking_ageblocking_querysql_kill_blocking_connection

locked_schemalocked_tablelocked_typewaiting_processlist_idwaiting_agewaiting_querywaiting_stateblocking_processlist_idblocking_ageblocking_querysql_kill_blocking_connection

NULL
thd_idconn_iduserdbcommandstatetimecurrent_statementstatement_latencyprogresslock_latencyrows_examinedrows_sentrows_affectedtmp_tablestmp_disk_tablesfull_scanlast_statementlast_statement_latencycurrent_memorylast_waitlast_wait_latencysourcetrx_latencytrx_statetrx_autocommitpidprogram_namelock_summary

object_schemaobject_namewaiting_thread_idwaiting_pidwaiting_accountwaiting_lock_typewaiting_lock_durationwaiting_querywaiting_query_secswaiting_query_rows_affectedwaiting_query_rows_examinedblocking_thread_idblocking_pidblocking_accountblocking_lock_typeblocking_lock_durationsql_kill_blocking_querysql_kill_blocking_connection

● 查看服务器的状态

[回到目录]


SQL部分


● 跟踪长时间操作的进度
THREAD_IDEVENT_IDEND_EVENT_IDEVENT_NAMESOURCETIMER_STARTTIMER_ENDTIMER_WAITWORK_COMPLETEDWORK_ESTIMATEDNESTING_EVENT_IDNESTING_EVENT_TYPE

● 查看平均执行时间值大于95%的平均执行时间的语句(可近似地认为是平均执行时间超长的语句),默认情况下按照语句平均延迟(执行时间)降序排序 NULL NULL NULL NULL
querydbfull_scanexec_counterr_countwarn_counttotal_latencymax_latencyavg_latencyrows_sentrows_sent_avgrows_examinedrows_examined_avgfirst_seenlast_seendigest

● 查看当前正在执行的语句进度信息
thd_idconn_iduserdbcommandstatetimecurrent_statementstatement_latencyprogresslock_latencyrows_examinedrows_sentrows_affectedtmp_tablestmp_disk_tablesfull_scanlast_statementlast_statement_latencycurrent_memorylast_waitlast_wait_latencysourcetrx_latencytrx_statetrx_autocommitpidprogram_name

● 查看已经执行完的语句相关统计信息
thd_idconn_iduserdbcommandstatetimecurrent_statementstatement_latencyprogresslock_latencyrows_examinedrows_sentrows_affectedtmp_tablestmp_disk_tablesfull_scanlast_statementlast_statement_latencycurrent_memorylast_waitlast_wait_latencysourcetrx_latencytrx_statetrx_autocommitpidprogram_name

● 查看使用了临时表的语句,默认情况下按照磁盘临时表数量和内存临时表数量进行降序排序
querydbexec_counttotal_latencymemory_tmp_tablesdisk_tmp_tablesavg_tmp_tables_per_querytmp_tables_to_disk_pctfirst_seenlast_seendigest
SELECT ? UNION ALL SELECT `con ... MIT ? ) `V` UNION ALL SELECT ?43.84 ms1243332022-04-08 10:57:10.8197582022-04-08 11:19:41.677440c2f0920e26e84d609a0962ab9bacb45804aece48f45228010822c564b710f943
SELECT ? UNION ALL SELECT `con ... - ? ) ) `V` UNION ALL SELECT ?43.89 ms1243332022-04-08 10:57:11.1121072022-04-08 11:19:41.97144587f263403e4a1aaf439a3b73f3c2c2498b4f3e85181498e2fe88f97aed7959b7
SELECT ? UNION ALL SELECT `con ... MIT ? ) `V` UNION ALL SELECT ?44.03 ms842502022-04-08 10:57:11.8461882022-04-08 11:19:42.702883a71f560a8e0c260d57080c81c9f5c83e3d60ad725a4a01fdd8102f8eed32282f
SELECT ? UNION ALL SELECT `con ... GINS` ) `V` UNION ALL SELECT ?46.53 ms4411002022-04-08 10:57:08.5461132022-04-08 11:19:38.880159c9c8560645bced1d0f2c0bd7c0874c6d451581ce3425b2efcc1b431c21536866
SELECT ? UNION ALL SELECT `con ... ` ( ) ) `V` UNION ALL SELECT ?43.45 ms4411002022-04-08 10:57:11.6034362022-04-08 11:19:42.4603692541f6d4972434db06768a3a92e024b72f7e52b7dbf1aa0320177313069e9828
SELECT ? UNION ALL SELECT `con ... ` = ? ) `V` UNION ALL SELECT ?33.27 ms3311002022-04-08 10:57:16.8164402022-04-08 11:18:55.998557937193685b21f68dfcd74005d63e109e89dbf18d899fd6899436b9ceafd712d7
SELECT ? UNION ALL SELECT `con ... - ? ) ) `V` UNION ALL SELECT ?21.89 ms623332022-04-08 11:18:50.6844982022-04-08 11:19:42.11928828a8cf0aee2963d7ef833895a67d515329bf3204c7c6df73a052b70d50a4ea23
SELECT ? UNION ALL SELECT `con ... - ? ) ) `V` UNION ALL SELECT ?21.9 ms623332022-04-08 10:57:11.2606782022-04-08 11:09:11.444207642b5ecf0eb82817a42cd32434ff07466bb8b88e805580fdcb19bd831055a930
SELECT `concat` ( ? , `ifnull` ... TION ( ? IN HOST ) - ? ) ) `V`11.44 ms313332022-04-08 11:15:23.1451582022-04-08 11:15:23.1451589912d114bdb0db0b052a3880bd0067e9f89d0d56745713eab94b4a96aaa2ef33
SELECT `concat` ( ? , `databas ... TION ( ? IN HOST ) - ? ) ) `V`11.76 ms313332022-04-08 11:10:49.3066952022-04-08 11:10:49.3066959cfd71d42688c678067b03076dfef242e3b218d6a0d88142e7e15e89c75ad57f

● 有临时表的前10条SQL语句
querydbfull_scanexec_counterr_countwarn_counttotal_latencymax_latencyavg_latencylock_latencyrows_sentrows_sent_avgrows_examinedrows_examined_avgrows_affectedrows_affected_avgtmp_tablestmp_disk_tablesrows_sortedsort_merge_passesdigestfirst_seenlast_seen
SELECT `internal_tablespace_id ... _ROWS` , ? AS `UPDATE_COUNT` ,*16001.90 s1.58 s118.62 ms33.09 ms108725561600028080056ebc6e21608c16d20579b17eca3668ef7bae51b1c1cdd8a0622ae1c146006ff2022-04-08 10:57:08.2464012022-04-08 11:19:40.944840
SELECT COUNT (?) AS `cnt` , `r ... y_by_digest` GROUP BY `avg_us`*40057.66 ms16.44 ms14.42 ms6.51 ms2054361090028024092ff97b05a2a2e654025eae1e78fdeafead5be7e942f76f5dcc937737c2f71382022-04-08 10:57:14.1462832022-04-08 11:19:44.803821
SELECT ( `cat` . `name` COLLAT ... ction_collation_id` ) ) ) JOIN*40085.46 ms40.09 ms21.37 ms20.85 ms3693690028000513931926a5cef8e76cd0f4279226f8e729f2ee6a83827c0b60522b1f566f0ef2022-04-08 10:57:08.9107042022-04-08 11:19:39.729505
SELECT `t` . `THREAD_ID` AS `t ... T_NUMBER_OF_BYTES_USED` ) DESC*400462.04 ms132.60 ms115.51 ms9.56 ms1232050024040102a5e41c03bf35093f51e81fb81b13e07005f0c742759ae7a75c10afa4cfe9c9d2022-04-08 10:57:13.3493742022-04-08 11:19:44.008150
SELECT ( `cat` . `name` COLLAT ... te_data` , COALESCE ( `stat` .*110059.99 ms6.91 ms5.45 ms13.02 ms62662600190240c0d9adc65303cbad4ff4e71fab7bb4f071392ea4456d3d741ce5b09be33c7dbf2022-04-08 10:57:09.8783362022-04-08 11:19:40.795331
SELECT `t` . `THREAD_ID` AS `t ... F_BYTES_USED` ) DESC (unknown)*80020.84 ms3.36 ms2.61 ms12.25 ms16216200160001564cd5c0d3704b0b7f27cfb3ea273ab3261f37040a5d3f51f2471f811db7a132022-04-08 10:57:14.2464232022-04-08 11:19:45.002062
SELECT ( `cat` . `name` COLLAT ... den` ) ) , COALESCE ( `stat` .*70040.26 ms9.08 ms5.75 ms9.47 ms146211786255001200065ac3bed35307c7b61b3d7f2ea0f6e94a087f4a2c830cd7d4d96182b73852d642022-04-08 10:57:09.5791602022-04-08 11:19:40.392265
SELECT ? UNION ALL SELECT `con ... DESC ) `V` UNION ALL SELECT ?*3032.23 ms775.34 us744.80 us1.17 ms6262001200023a299fabdfca3771d2e39118c51cf18d337f0a47e58d576ca55e2b325fe31b92022-04-08 10:57:14.8917862022-04-08 11:18:54.066369
SELECT ? UNION ALL SELECT `con ... MIT ? ) `V` UNION ALL SELECT ?*4003.84 ms997.95 us961.12 us1.81 ms1641640012400c2f0920e26e84d609a0962ab9bacb45804aece48f45228010822c564b710f9432022-04-08 10:57:10.8197582022-04-08 11:19:41.677440
SELECT ? UNION ALL SELECT `con ... - ? ) ) `V` UNION ALL SELECT ?*4003.89 ms1.02 ms971.85 us1.85 ms164164001240087f263403e4a1aaf439a3b73f3c2c2498b4f3e85181498e2fe88f97aed7959b72022-04-08 10:57:11.1121072022-04-08 11:19:41.971445

● 查看执行了文件排序的语句,默认情况下按照语句总延迟时间(执行时间)降序排序 NULL NULL NULL NULL NULL NULL NULL NULL NULL
querydbexec_counttotal_latencysort_merge_passesavg_sort_mergessorts_using_scanssort_using_rangerows_sortedavg_rows_sortedfirst_seenlast_seendigest

● 查询SQL的整体消耗百分比
statetotal_rpct_rcallsr/call

● 执行次数Top10
querydbfull_scanexec_counterr_countwarn_counttotal_latencymax_latencyavg_latencylock_latencyrows_sentrows_sent_avgrows_examinedrows_examined_avgrows_affectedrows_affected_avgtmp_tablestmp_disk_tablesrows_sortedsort_merge_passesdigestfirst_seenlast_seen
SELECT `internal_tablespace_id ... _ROWS` , ? AS `UPDATE_COUNT` ,*16001.90 s1.58 s118.62 ms33.09 ms108725561600028080056ebc6e21608c16d20579b17eca3668ef7bae51b1c1cdd8a0622ae1c146006ff2022-04-08 10:57:08.2464012022-04-08 11:19:40.944840
SELECT ( `cat` . `name` COLLAT ... te_data` , COALESCE ( `stat` .*110059.99 ms6.91 ms5.45 ms13.02 ms62662600190240c0d9adc65303cbad4ff4e71fab7bb4f071392ea4456d3d741ce5b09be33c7dbf2022-04-08 10:57:09.8783362022-04-08 11:19:40.795331
SELECT `t` . `THREAD_ID` AS `t ... F_BYTES_USED` ) DESC (unknown)*80020.84 ms3.36 ms2.61 ms12.25 ms16216200160001564cd5c0d3704b0b7f27cfb3ea273ab3261f37040a5d3f51f2471f811db7a132022-04-08 10:57:14.2464232022-04-08 11:19:45.002062
SELECT ( `cat` . `name` COLLAT ... den` ) ) , COALESCE ( `stat` .*70040.26 ms9.08 ms5.75 ms9.47 ms146211786255001200065ac3bed35307c7b61b3d7f2ea0f6e94a087f4a2c830cd7d4d96182b73852d642022-04-08 10:57:09.5791602022-04-08 11:19:40.392265
SELECT `sys` . `format_stateme ... atency` , `format_pico_time` (*70028.45 ms4.44 ms4.06 ms5.09 ms841284120070700508486bd060b13d75e7374136fec54ea4e8827b60fbb8fac7aded21a9ecf3c8a2022-04-08 10:57:14.5966312022-04-08 11:19:45.258692
SHOW GLOBAL VARIABLES WHERE `V ... l_variables` . `VARIABLE_NAME`*70026.02 ms5.11 ms3.72 ms2.50 ms15823158230070003843bbd6565b5be5ced26d3cd6b87c95388208a8bda45858bee0ef931b4dbfb12022-04-08 10:57:10.6231872022-04-08 11:19:41.482724
SHOW VARIABLES LIKE ? (unknown ... n_variables` . `VARIABLE_NAME`*40019.64 ms6.16 ms4.91 ms801.00 us205205004000a87043a2f1fedffea3d9eb9c3f1ea4066dbb6481c035609112a31b4425b3aac92022-04-08 10:57:08.3983442022-04-08 11:19:38.727789
SELECT ? UNION ALL SELECT `con ... GINS` ) `V` UNION ALL SELECT ?*4006.53 ms1.69 ms1.63 ms2.82 ms2085220852004400c9c8560645bced1d0f2c0bd7c0874c6d451581ce3425b2efcc1b431c215368662022-04-08 10:57:08.5461132022-04-08 11:19:38.880159
SELECT ( `cat` . `name` COLLAT ... ction_collation_id` ) ) ) JOIN*40085.46 ms40.09 ms21.37 ms20.85 ms3693690028000513931926a5cef8e76cd0f4279226f8e729f2ee6a83827c0b60522b1f566f0ef2022-04-08 10:57:08.9107042022-04-08 11:19:39.729505
SELECT ? UNION ALL SELECT `con ... INES` ) `V` UNION ALL SELECT ?*4002.12 ms555.00 us529.12 us1.05 ms44114411004000d3a5b69de359299423c84c180dc32c5945166dab355a2dce7c2a5028ed74cbde2022-04-08 10:57:09.7260942022-04-08 11:19:40.539108

● 使用全表扫描的SQL语句
object_schemaobject_namerows_full_scannedlatency

● 查看全表扫描或者没有使用到最优索引的语句(经过标准化转化的语句文本),默认情况下按照全表扫描次数与语句总次数百分比和语句总延迟时间(执行时间)降序排序 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
querydbexec_counttotal_latencyno_index_used_countno_good_index_used_countno_index_used_pctrows_sentrows_examinedrows_sent_avgrows_examined_avgfirst_seenlast_seendigest

● 查看产生错误或警告的语句,默认情况下,按照错误数量和警告数量降序排序
querydbexec_counterrorserror_pctwarningswarning_pctfirst_seenlast_seendigest
SELECT ? UNION ALL SELECT `con ... DESC ) `V` UNION ALL SELECT ?400.00004100.00002022-04-08 10:57:14.8917862022-04-08 11:19:45.60535523a299fabdfca3771d2e39118c51cf18d337f0a47e58d576ca55e2b325fe31b9
SHOW SLAVE HOSTS300.00003100.00002022-04-08 10:57:17.2538472022-04-08 11:18:56.437664f59f2dee8175a875cdb3093ec4d2e4e82f9198f48fd99b6090cf6f00ebc3321e
SHOW SLAVE STATUS300.00003100.00002022-04-08 10:57:17.8925582022-04-08 11:18:57.080809aeea8d14c430e6eaaf2ffc1c542f366c21a261cbe130323702b18c3c36cf92ae

[回到目录]


索引部分


● 冗余索引

● 无效索引(从未使用过的索引)
object_schemaobject_nameindex_name
performance_schemacond_instancesNAME
performance_schemadata_lock_waitsREQUESTING_ENGINE_LOCK_ID
performance_schemadata_lock_waitsBLOCKING_ENGINE_LOCK_ID
performance_schemadata_lock_waitsREQUESTING_ENGINE_TRANSACTION_ID
performance_schemadata_lock_waitsBLOCKING_ENGINE_TRANSACTION_ID
performance_schemadata_lock_waitsREQUESTING_THREAD_ID
performance_schemadata_lock_waitsBLOCKING_THREAD_ID
performance_schemadata_locksENGINE_TRANSACTION_ID
performance_schemadata_locksTHREAD_ID
performance_schemadata_locksOBJECT_SCHEMA
performance_schemaerror_logTHREAD_ID
performance_schemaerror_logPRIO
performance_schemaerror_logERROR_CODE
performance_schemaerror_logSUBSYSTEM
performance_schemaevents_waits_summary_by_instanceEVENT_NAME
performance_schemafile_instancesEVENT_NAME
performance_schemafile_summary_by_instanceFILE_NAME
performance_schemafile_summary_by_instanceEVENT_NAME
performance_schemahost_cacheHOST
performance_schemametadata_locksOBJECT_TYPE
performance_schemametadata_locksOWNER_THREAD_ID
performance_schemamutex_instancesNAME
performance_schemamutex_instancesLOCKED_BY_THREAD_ID
performance_schemaprepared_statements_instancesSTATEMENT_ID
performance_schemaprepared_statements_instancesSTATEMENT_NAME
performance_schemaprepared_statements_instancesOWNER_OBJECT_TYPE
performance_schemareplication_applier_status_by_coordinatorTHREAD_ID
performance_schemareplication_applier_status_by_workerTHREAD_ID
performance_schemareplication_asynchronous_connection_failoverCHANNEL_NAME
performance_schemareplication_connection_statusTHREAD_ID
performance_schemarwlock_instancesNAME
performance_schemarwlock_instancesWRITE_LOCKED_BY_THREAD_ID
performance_schemasocket_instancesTHREAD_ID
performance_schemasocket_instancesSOCKET_ID
performance_schemasocket_instancesIP
performance_schemasocket_summary_by_instanceEVENT_NAME
performance_schematable_handlesOBJECT_TYPE
performance_schematable_handlesOWNER_THREAD_ID
performance_schemathreadsPROCESSLIST_ID
performance_schemathreadsTHREAD_OS_ID
performance_schemathreadsNAME
performance_schemathreadsPROCESSLIST_ACCOUNT
performance_schemathreadsPROCESSLIST_HOST
performance_schemathreadsRESOURCE_GROUP

● 每张表的索引区分度(前100条)

区分度越接近1,表示区分度越高;低于0.1,则说明区分度较差,开发者应该重新评估SQL语句涉及的字段,选择区分度高的多个字段创建索引
ASdbAStableASindex_nameAScolsASdefferRowsASROWSsel_persent

[回到目录]


主从情况


● 主从复制涉及到的重要参数

● 主从库线程
THREAD_IDNAMETYPEPROCESSLIST_IDPROCESSLIST_USERPROCESSLIST_HOSTPROCESSLIST_DBPROCESSLIST_COMMANDPROCESSLIST_TIMEPROCESSLIST_STATEPROCESSLIST_INFOPARENT_THREAD_IDROLEINSTRUMENTEDHISTORYCONNECTION_TYPETHREAD_OS_ID

IDUSERHOSTDBCOMMANDTIMESTATEINFO

● 二进制日志
binlog.000001 179 No binlog.000002 156 No

● 主库端查看所有从库

● MGR详情 NULL
CHANNEL_NAMEMEMBER_IDMEMBER_HOSTMEMBER_PORTMEMBER_STATEMEMBER_ROLEMEMBER_VERSIONMEMBER_COMMUNICATION_STACK

● 主库状态监测

● 从库状态监测(需要在从库执行才有数据)

CHANNEL_NAMEHOSTPORTUSERCONNECTION_RETRY_COUNTCONNECTION_RETRY_INTERVALSOURCE_UUIDTHREAD_IDSERVICE_STATECOUNT_RECEIVED_HEARTBEATSLAST_HEARTBEAT_TIMESTAMPLAST_ERROR_NUMBERLAST_ERROR_MESSAGELAST_ERROR_TIMESTAMP

● 克隆进度和状态
IDPIDSTATEBEGIN_TIMEEND_TIMESOURCEDESTINATIONERROR_NOERROR_MESSAGEBINLOG_FILEBINLOG_POSITIONGTID_EXECUTED

stagestateSTART TIMEFINISH TIMEDURATIONEstimateDone(%)

[回到目录]


数据库性能


● 性能参数统计

[回到目录]


其它


● setup_consumers
NAMEENABLED
events_stages_currentNO
events_stages_historyNO
events_stages_history_longNO
events_statements_currentYES
events_statements_historyYES
events_statements_history_longNO
events_transactions_currentYES
events_transactions_historyYES
events_transactions_history_longNO
events_waits_currentNO
events_waits_historyNO
events_waits_history_longNO
global_instrumentationYES
thread_instrumentationYES
statements_digestYES

● 自增ID的使用情况(前20条)
table_schematable_nameengineAuto_increment

● 无主键或唯一键的表(前100条)
table_schematable_name

[回到目录]