从mysqltuner.pl调优建议:query_cache_limit

mysqltuner.pl脚本给了我以下建议:

query_cache_limit (> 1M, or use smaller result sets)

MySQL状态输出显示:

mysql> SHOW STATUS LIKE 'Qcache%';
+-------------------------+------------+
| Variable_name           | Value      |
+-------------------------+------------+
| Qcache_free_blocks      | 12264      | 
| Qcache_free_memory      | 1001213144 | 
| Qcache_hits             | 3763384    | 
| Qcache_inserts          | 54632419   | 
| Qcache_lowmem_prunes    | 0          | 
| Qcache_not_cached       | 6656246    | 
| Qcache_queries_in_cache | 55280      | 
| Qcache_total_blocks     | 122848     | 
+-------------------------+------------+
8 rows in set (0.00 sec)

从上面的状态输出,我如何判断是否需要建议增加query_cache_limit?

最好的办法是设置一些在数据库上执行现实(由场景定义)加载的测试工具,然后使用不同的设置对MySql运行该测试.调整本身就是这样一种艺术,在不知道你的确切需要的情况下,很难给出所有拥抱的答案.

http://dev.mysql.com/tech-resources/articles/mysql-query-cache.html

The Qcache_free_memory counter
provides insight into the cache’s free
memory. Low amounts observed vs. total
allocated for the cache may indicate
an undersized cache, which can be
remedied by altering the global
variable query_cache_size.

Qcache_hits and Qcache_inserts shows
the number of times a query was
serviced from the cache and how many
queries have been inserted into the
cache. Low ratios of hits to inserts
indicate little query reuse or a
too-low setting of the
query_cache_limit, which serves to
govern the RAM devoted to each
individual query cache entry. Large
query result sets will require larger
settings of this variable.

Another indicator of poor query reuse
is an increasing Qcache_lowmem_prunes
value. This indicates how often MySQL
had to remove queries from the cache
to make use for incoming statements.
Other reasons for an increasing number
of Qcache_lowmem_prunes are an
undersized cache, which can’t hold the
needed amount of SQL statements and
result sets, and memory fragmentation
in the cache which may be alleviated
by issuing a FLUSH QUERY CACHE
statement. You can remove all queries
from the cache with the RESET QUERY
CACHE command.

The Qcache_not_cached counter provides
insight into the number of statements
executed against MySQL that were not
cacheable, due to either being a
non-SELECT statement or being
explicitly barred from entry with a
SQL_NO_CACHE hint.

您的点击率插入比例是1:15或6%,所以看起来你的设置可以用一些finetuning(尽管如我所说,你是最好的法官,因为你最了解你的要求).

转载注明原文:从mysqltuner.pl调优建议:query_cache_limit - 代码日志