{"id":1146,"date":"2011-12-19T11:33:00","date_gmt":"2011-12-19T03:33:00","guid":{"rendered":"\/?p=1146"},"modified":"2012-01-12T10:36:08","modified_gmt":"2012-01-12T02:36:08","slug":"mysql-query-cache","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/mysql\/mysql-query-cache.html","title":{"rendered":"MySQL Query Cache \u8fd0\u884c\u53c2\u6570\u53ca\u72b6\u6001\u68c0\u6d4b"},"content":{"rendered":"

MySQL\u7684Query Cache\u7cfb\u7edf\u53d8\u91cf\u90fd\u662f\u4ee5\u201cquery_cache\u201c\u4f5c\u4e3a\u524d\u540e\u7f00\u7684\uff0c\u5b83\u4eec\u5206\u522b\u662f\uff1a<\/p>\n

have_query_cache<\/strong>
\nquery_cache_limit<\/strong>
\nquery_cache_min_res_unit<\/strong>
\nquery_cache_size<\/strong>
\nquery_cache_type<\/strong>
\nquery_cache_wlock_invalidate<\/strong><\/p>\n

\u5176\u4e2d\u201dhave_query_cache\u201c\u53d8\u91cf\u6807\u8bc6\u662fQueryCache\u662f\u5426\u53ef\u7528\u3002\u53ef\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\uff1a<\/p>\n

\"\"<\/a><\/p>\n

\u901a\u5e38\u8fd9\u4e2a\u53d8\u91cf\u503c\u4e3aYES\uff0c\u5373\u4f7fQueryCache\u529f\u80fd\u4e0d\u53ef\u7528\u7684\u65f6\u5019\uff1a\u5f53\u201cquery_cache_size\u201d\u7684\u503c\u4e3a0\u7684\u65f6\u5019\uff0c\u5373\u4f7f”have_query_cache=YES”,QueryCache\u4e5f\u4e0d\u53ef\u7528\u3002<\/p>\n

\u6807\u51c6\u7248MySQL\u4e2d\u201cquery_cache_size\u201d\u4e3a0\uff0c\u4e5f\u5373\uff0c\u9ed8\u8ba4\u914d\u7f6e\u4e0bQueryCache\u662f\u4e0d\u53ef\u7528\u7684\u3002<\/strong><\/span><\/span><\/p>\n

\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u3001\u542f\u52a8\u53c2\u6570\u548c\u547d\u4ee4\u8bbe\u7f6e\u76f8\u5173\u53c2\u6570\u3002\u5982\u901a\u8fc7”SET”\u547d\u4ee4\u8bbe\u7f6e\u201cquery_cache_size\u201d:<\/p>\n

\u5168\u5c40\u8bbe\u7f6e\uff1a<\/strong>mysql> <\/span>SET GLOBAL query_cache_size = 1048576;
\n<\/span>\u4f1a\u8bdd\u8bbe\u7f6e\uff1a<\/strong>mysql> SET SESSION query_cache_size = 1048576;<\/p>\n

\u00a0\u00a0<\/strong><\/span>\u00a0\u00a0<\/strong>\u00a0\u00a0<\/strong>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u65f6\u5019\u6807\u51c6\u00a0MySQL \u5206\u53d1\u7248\u7684\u8bdd\uff0cQuery Cache \u529f\u80fd\u9ed8\u8ba4\u90fd\u662f\u6253\u5f00\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574 MySQL Server \u7684\u53c2\u6570\u9009\u9879\u6253\u5f00\u8be5\u529f\u80fd\u3002\u5b83\u4eec\u4e3b\u8981\u7531\u4ee5\u4e0b5\u4e2a\u53c2\u6570\u6784\u6210\uff1a<\/p>\n