14.5 INFORMATION_SCHEMA and Data Dictionary Integration数据字典集成

With the introduction of the data dictionary, the following INFORMATION_SCHEMA tables are implemented as views on data dictionary tables:随着数据字典的引入,以下INFORMATION_SCHEMA表作为数据字典表的视图实现:

Queries on those tables are now more efficient because they obtain information from data dictionary tables rather than by other, slower means. 对这些表的查询现在效率更高,因为它们从数据字典表中获取信息,而不是通过其他较慢的方式。In particular, for each INFORMATION_SCHEMA table that is a view on data dictionary tables:特别是,对于作为数据字典表视图的每个INFORMATION_SCHEMA表:

The preceding improvements also apply to SHOW statements that display information corresponding to the INFORMATION_SCHEMA tables that are views on data dictionary tables. 前面的改进也适用于SHOW语句,这些语句显示与作为数据字典表视图的INFORMATION_SCHEMA表相对应的信息。For example, SHOW DATABASES displays the same information as the SCHEMATA table.例如,SHOW DATABASES显示与SCHEMATA表相同的信息。

In addition to the introduction of views on data dictionary tables, table statistics contained in the STATISTICS and TABLES tables is now cached to improve INFORMATION_SCHEMA query performance. 除了引入数据字典表的视图外,现在还缓存了STATISTICSTABLES表中包含的表统计信息,以提高INFORMATION_SCHEMA查询性能。The information_schema_stats_expiry system variable defines the period of time before cached table statistics expire. information_schema_stats_expiry系统变量定义了缓存表统计数据过期之前的时间段。The default is 86400 seconds (24 hours). 默认值为86400秒(24小时)。If there are no cached statistics or statistics have expired, statistics are retrieved from storage engine when querying table statistics columns. 如果没有缓存的统计信息或统计信息已过期,则在查询表统计信息列时,将从存储引擎中检索统计信息。To update cached values at any time for a given table, use ANALYZE TABLE要随时更新给定表的缓存值,请使用ANALYZE TABLE

information_schema_stats_expiry can be set to 0 to have INFORMATION_SCHEMA queries retrieve the latest statistics directly from the storage engine, which is not as fast as retrieving cached statistics.information_schema_stats_expiry可以设置为0,以使INFORMATION_SCHEMA查询直接从存储引擎检索最新的统计信息,这不如检索缓存的统计信息快。

For more information, see Section 8.2.3, “Optimizing INFORMATION_SCHEMA Queries”.有关更多信息,请参阅第8.2.3节,“优化信息和模式查询”

INFORMATION_SCHEMA tables in MySQL 8.0 are closely tied to the data dictionary, resulting in several usage differences. MySQL 8.0中的INFORMATION_SCHEMA表与数据字典紧密相连,导致了一些使用差异。See Section 14.7, “Data Dictionary Usage Differences”.请参阅第14.7节,“数据字典使用差异”