19.5 内存使用顾问

本节介绍基于表达式的内存使用顾问程序。

InnoDB 缓冲区缓存具有次优命中率

逻辑 I/O 比物理 I/O 快很多倍,因此 DBA 应该努力将物理 I/O 保持在最低限度。逻辑 I/O 确实不是免费的,DBA 应该努力将所有 I/O 保持在最低限度,但最好是在内存中执行大部分数据访问。使用 InnoDB 时,大部分数据访问应该发生在内存中,因此 InnoDB buffer cache 的命中率应该很高。

默认频率00:05:00

默认自动关闭是否启用

密钥缓冲区大小可能不是密钥缓存的最佳选择

键缓存命中率表示从内存中的键缓存而不是从磁盘中读取的键的比例。为了获得最佳效率,该值通常应大于 99%。

默认频率00:05:00

默认自动关闭是否启用

查询缓存具有次优命中率

笔记

此顾问不会针对 MySQL 8 或更高版本进行评估。

When enabled, the query cache should experience a high degree of hits, meaning that queries in the cache are being reused by other user connections. A low hit rate may indicate not enough memory is allocated to the cache, identical queries are not being issued repeatedly to the server, or that the statements in the query cache are invalidated too frequently by INSERT, UPDATE, or DELETE statements.

This advisor triggers when more than 25% of the Query Cache is being used, and the ratio of Query Cache hits to Query Cache inserts is low.

Default frequency 00:05:00

Default auto-close enabled no

Query Cache Potentially Undersized

Note

This advisor does not evaluate against MySQL 8, or higher.

When the Query Cache is full, and needs to add more queries to the cache, it makes more room in the cache by freeing the least recently used queries from the cache, and then inserting the new queries. If this is happening often, increase the size of the cache to avoid this swapping.

Default frequency 00:05:00

Default auto-close enabled no

Table Cache Not Optimal

MySQL is multi-threaded, so there may be many clients issuing queries for a given table simultaneously. To minimize the problem of multiple client threads having different states on the same table, the table is opened independently by each concurrent thread.

The table cache is used to cache file descriptors for open tables and there is a single cache shared by all clients. Increasing the size of the table cache allows mysqld to keep more tables open simultaneously by reducing the number of file open and close operations that must be done. If the value of Open_tables is approaching the value of table_open_cache, this may indicate performance problems.

Default frequency 00:05:00

Default auto-close enabled no

Thread Cache Size May Not Be Optimal

与 MySQL 数据库服务器的每个连接都在其自己的线程中运行。线程创建需要时间,因此服务器可以将线程保留在其线程缓存中并在以后将其用于新连接,而不是在连接关闭时终止线程。

默认频率00:05:00

默认自动关闭是否启用