在繁忙的 mysql 服务器上,无论我如何增加该值(我尝试将其增加到 512MB),MySQLTuner 1.2.0 始终建议添加 query_cache_size。另一方面,它警告:
Increasing the query_cache size over 128M may reduce performance
以下是最后的结果:
>> MySQLTuner 1.2.0 - Major Hayden <[email protected]>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.5.25-1~dotdeb.0-log
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in InnoDB tables: 6G (Tables: 195)
[--] Data in PERFORMANCE_SCHEMA tables: 0B (Tables: 17)
[!!] Total fragmented tables: 51
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 1d 19h 17m 8s (254M q [1K qps], 5M conn, TX: 139B, RX: 32B)
[--] Reads / Writes: 89% / 11%
[--] Total buffers: 24.2G global + 92.2M per thread (1200 max threads)
[!!] Maximum possible memory usage: 132.2G (139% of installed RAM)
[OK] Slow queries: 0% (2K/254M)
[OK] Highest usage of available connections: 32% (391/1200)
[OK] Key buffer size / total MyISAM indexes: 128.0M/92.0K
[OK] Key buffer hit rate: 100.0% (8B cached / 0 reads)
[OK] Query cache efficiency: 79.9% (181M cached / 226M selects)
[!!] Query cache prunes per day: 1033203
[OK] Sorts requiring temporary tables: 0% (341 temp sorts / 4M sorts)
[OK] Temporary tables created on disk: 14% (760K on disk / 5M total)
[OK] Thread cache hit rate: 99% (676 created / 5M connections)
[OK] Table cache hit rate: 22% (1K open / 8K opened)
[OK] Open file limit used: 0% (49/13K)
[OK] Table locks acquired immediately: 99% (64M immediate / 64M locks)
[OK] InnoDB data size / buffer pool: 6.1G/19.5G
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Reduce your overall MySQL memory footprint for system stability
Increasing the query_cache size over 128M may reduce performance
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (> 192M) [see warning above]
该服务器有 76GB 内存和双 E5-2650。负载通常低于 2。感谢您提供的提示,以解释建议并优化数据库配置。
答案1
MySQL 查询缓存大小是一篇您可能觉得有用的博客文章。
概括起来就是,一旦 query_cache 超过一定大小,MySQL 管理缓存的时间就会比使用缓存的时间要长。每次影响查询结果的写入都会使缓存中的结果无效。
如果您的应用程序主要是读取数据库,那么较大的查询缓存大小将大有裨益。如果您的应用程序是重度写入型,那么较低的缓存或根本没有缓存将大有裨益。
请注意,还有许多其他博客文章讨论较大的 query_cache 大小,但最后他们都说您必须在您的环境中实际测试设置以获得最佳设置。