文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 28 个 INFORMATION_SCHEMA 表 / 28.4 INFORMATION_SCHEMA InnoDB 表 / 28.4.5 INFORMATION_SCHEMA INNODB_CACHED_INDEXES 表
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 81%

28.4.5 INFORMATION_SCHEMA INNODB_CACHED_INDEXES 表28.4.5 The INFORMATION_SCHEMA INNODB_CACHED_INDEXES Table

INNODB_CACHED_INDEXES 表报告了 InnoDB 缓冲池中每个索引缓存的索引页面数量。The INNODB_CACHED_INDEXES table reports the number of index pages cached in the InnoDB buffer pool for each index.

有关相关用法信息和示例,请参见 第 17.15.5 节,“InnoDB INFORMATION_SCHEMA 缓冲池表”。For related usage information and examples, see Section 17.15.5, “InnoDB INFORMATION_SCHEMA Buffer Pool Tables”.

INNODB_CACHED_INDEXES 表包含以下列:The INNODB_CACHED_INDEXES table has these columns:

  • SPACE_ID

    表空间 ID。The tablespace ID.

  • INDEX_ID

    索引的标识符。索引标识符在实例的所有数据库中都是唯一的。An identifier for the index. Index identifiers are unique across all the databases in an instance.

  • N_CACHED_PAGES

    自 MySQL 服务器上次启动以来,特定索引在 InnoDB 缓冲池中缓存的索引页总数。The total number of index pages cached in the InnoDB buffer pool for a specific index since MySQL Server last started.

示例Examples

此查询返回特定索引在 InnoDB 缓冲池中缓存的索引页数:This query returns the number of index pages cached in the InnoDB buffer pool for a specific index:

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_CACHED_INDEXES WHERE INDEX_ID=65\G
*************************** 1. row ***************************
      SPACE_ID: 4294967294
      INDEX_ID: 65
N_CACHED_PAGES: 45

此查询返回每个索引在 InnoDB 缓冲池中缓存的索引页数,使用 INNODB_INDEXES 和 INNODB_TABLES 表来解析每个 INDEX_ID 对应的表名和索引名。This query returns the number of index pages cached in the InnoDB buffer pool for each index, using the INNODB_INDEXES and INNODB_TABLES tables to resolve the table name and index name for each INDEX_ID value.

SELECT
  tables.NAME AS table_name,
  indexes.NAME AS index_name,
  cached.N_CACHED_PAGES AS n_cached_pages
FROM
  INFORMATION_SCHEMA.INNODB_CACHED_INDEXES AS cached,
  INFORMATION_SCHEMA.INNODB_INDEXES AS indexes,
  INFORMATION_SCHEMA.INNODB_TABLES AS tables
WHERE
  cached.INDEX_ID = indexes.INDEX_ID
  AND indexes.TABLE_ID = tables.TABLE_ID;

注意事项Notes

  • 你必须拥有 PROCESS 权限才能查询此表。You must have the PROCESS privilege to query this table.

  • 使用 INFORMATION_SCHEMA COLUMNS 表或 SHOW COLUMNS 语句查看关于此表列的更多信息,包括数据类型和默认值。Use the INFORMATION_SCHEMA COLUMNS table or the SHOW COLUMNS statement to view additional information about the columns of this table, including data types and default values.