INNODB_METRICS 表提供了各种各样的 InnoDB 性能信息,补充了 Performance Schema 表对 InnoDB 的特定关注领域。通过简单的查询,您可以检查系统的整体健康状况。通过更详细的查询,您可以诊断诸如性能瓶颈、资源短缺和应用程序问题等问题。The INNODB_METRICS table provides a
wide variety of InnoDB performance information,
complementing the specific focus areas of the Performance Schema
tables for InnoDB. With simple queries, you can
check the overall health of the system. With more detailed
queries, you can diagnose issues such as performance bottlenecks,
resource shortages, and application issues.
每个监控器代表 InnoDB 源代码中的一个点,该点被仪器化以收集计数器信息。每个计数器可以启动、停止和重置。您还可以使用它们的公共模块名称对一组计数器执行这些操作。Each monitor represents a point within the
InnoDB source code that is instrumented to
gather counter information. Each counter can be started, stopped,
and reset. You can also perform these actions for a group of
counters using their common module name.
默认情况下,收集的数据相对较少。要启动、停止和重置计数器,请设置以下系统变量之一 innodb_monitor_enable、innodb_monitor_disable、innodb_monitor_reset 或 innodb_monitor_reset_all,使用计数器名称、模块名称、使用 “%” 字符的通配符匹配名称,或使用特殊关键字 all。By default, relatively little data is collected. To start, stop,
and reset counters, set one of the system variables
innodb_monitor_enable,
innodb_monitor_disable,
innodb_monitor_reset, or
innodb_monitor_reset_all, using
the name of the counter, the name of the module, a wildcard match
for such a name using the “%” character, or the
special keyword all.
有关使用信息,请参阅 第 17.15.6 节,“InnoDB INFORMATION_SCHEMA 指标表”。For usage information, see Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”.
INNODB_METRICS 表具有以下列:The INNODB_METRICS table has these
columns:
NAMENAME计数器的唯一名称。A unique name for the counter.
SUBSYSTEM指标所适用的
InnoDB方面。The aspect ofInnoDBthat the metric applies to.COUNTCOUNT自计数器启用以来的值。The value since the counter was enabled.
MAX_COUNT自计数器启用以来的最大值。The maximum value since the counter was enabled.
MIN_COUNT自计数器启用以来的最小值。The minimum value since the counter was enabled.
AVG_COUNT自计数器启用以来的平均值。The average value since the counter was enabled.
COUNT_RESET自上次重置以来的计数器值。(带有
_RESET的列就像秒表上的圈数计数器:您可以测量某个时间间隔内的活动,同时累积数据仍然可以在COUNT、MAX_COUNT等列中查看。)The counter value since it was last reset. (The_RESETcolumns act like the lap counter on a stopwatch: you can measure the activity during some time interval, while the cumulative figures are still available inCOUNT,MAX_COUNT, and so on.)MAX_COUNT_RESET自上次重置以来的计数器最大值。The maximum counter value since it was last reset.
MIN_COUNT_RESET自上次重置以来的计数器最小值。The minimum counter value since it was last reset.
AVG_COUNT_RESET自上次重置以来的计数器平均值。The average counter value since it was last reset.
TIME_ENABLED上次启动的时间戳。The timestamp of the last start.
TIME_DISABLED上一次停止的时间戳。The timestamp of the last stop.
TIME_ELAPSED计数器启动以来经过的秒数。The elapsed time in seconds since the counter started.
TIME_RESET上一次重置的时间戳。The timestamp of the last reset.
STATUSSTATUS计数器是否仍在运行(
enabled)或已停止(disabled)。Whether the counter is still running (enabled) or stopped (disabled).TYPETYPE项目是累积计数器,还是测量某个资源的当前值。Whether the item is a cumulative counter, or measures the current value of some resource.
COMMENTCOMMENT计数器描述。The counter description.
示例Example
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME='dml_inserts'\G
*************************** 1. row ***************************
NAME: dml_inserts
SUBSYSTEM: dml
COUNT: 3
MAX_COUNT: 3
MIN_COUNT: NULL
AVG_COUNT: 0.046153846153846156
COUNT_RESET: 3
MAX_COUNT_RESET: 3
MIN_COUNT_RESET: NULL
AVG_COUNT_RESET: NULL
TIME_ENABLED: 2014-12-04 14:18:28
TIME_DISABLED: NULL
TIME_ELAPSED: 65
TIME_RESET: NULL
STATUS: enabled
TYPE: status_counter
COMMENT: Number of rows inserted
备注Notes
你必须拥有
PROCESS权限才能查询此表。You must have thePROCESSprivilege to query this table.使用
INFORMATION_SCHEMACOLUMNS表或SHOW COLUMNS语句查看关于此表列的更多信息,包括数据类型和默认值。Use theINFORMATION_SCHEMACOLUMNStable or theSHOW COLUMNSstatement to view additional information about the columns of this table, including data types and default values.事务计数器
COUNT的值可能与性能模式EVENTS_TRANSACTIONS_SUMMARY表中报告的事务事件数量不同。InnoDB仅计算其执行的事务,而性能模式收集服务器发起的所有未中止事务的事件,包括空事务。Transaction counterCOUNTvalues may differ from the number of transaction events reported in Performance SchemaEVENTS_TRANSACTIONS_SUMMARYtables.InnoDBcounts only those transactions that it executes, whereas Performance Schema collects events for all non-aborted transactions initiated by the server, including empty transactions.