MySQL Variables query_cache_size 数据库 参数变量解释及正确配置使用

本站中文解释

query_cache_size参数用于控制MySQL服务器在内存中缓存查询结果的大小。该参数可以用来改善系统性能,如果非常频繁的执行相同的查询,可以将查询结果的缓存,以减少系统资源的消耗和提升查询速度。

query_cache_size参数的设置值应该由当前在该服务器上运行的应用来决定。推荐设置query_cache_size参数值介于64-256M之间,具体设置值依据查询的情况及服务器内存大小等因素做出适当的调整。

可以通过以下命令设置query_cache_size参数:
SET GLOBAL query_cache_size = 80*1024*1024;
在运行该命令后,MySQL服务器将分配 80M 的内存给查询结果的缓存。

官方英文解释

query_cache_size

Command-Line Format --query-cache-size=#
Deprecated 5.7.20
System Variable query_cache_size
Scope Global
Dynamic Yes
Type Integer
Default Value 1048576
Minimum Value 0
Maximum Value (64-bit platforms) 18446744073709551615
Maximum Value (32-bit platforms) 4294967295
Unit bytes

The amount of memory allocated for caching query results. By
default, the query cache is disabled. This is achieved using a
default value of 1M, with a default for
query_cache_type of 0. (To
reduce overhead significantly if you set the size to 0, you
should also start the server with
query_cache_type=0.

The permissible values are multiples of 1024; other values are
rounded down to the nearest multiple. For nonzero values of
query_cache_size, that many
bytes of memory are allocated even if
query_cache_type=0. See
Section 8.10.3.3, “Query Cache Configuration”, for more
information.

The query cache needs a minimum size of about 40KB to allocate
its structures. (The exact size depends on system
architecture.) If you set the value of
query_cache_size too small, a
warning occurs, as described in
Section 8.10.3.3, “Query Cache Configuration”.

Note

The query cache is deprecated as of MySQL 5.7.20, and is
removed in MySQL 8.0. Deprecation includes
query_cache_size.


数据运维技术 » MySQL Variables query_cache_size 数据库 参数变量解释及正确配置使用