{"id":2132,"date":"2014-04-19T20:46:23","date_gmt":"2014-04-19T12:46:23","guid":{"rendered":"http:\/\/www.huzs.top\/?p=2132"},"modified":"2014-04-19T20:46:23","modified_gmt":"2014-04-19T12:46:23","slug":"mysql%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.huzs.top\/?p=2132","title":{"rendered":"MySQL\u4f18\u5316"},"content":{"rendered":"<p>\u67e5\u770b\u8bbe\u7f6e\uff1a<br \/><code>mysql> SHOW VARIABLES LIKE 'query_cache%';<\/code><br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<br \/>| Variable_name                | Value    |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<br \/>| query_cache_limit            | 1048576  |  \u8d85\u8fc7\u6b64\u5927\u5c0f\u7684\u67e5\u8be2\u5c06\u4e0d\u7f13\u5b58<br \/>| query_cache_min_res_unit     | 4096     |  \u7f13\u5b58\u5757\u7684\u6700\u5c0f\u5927\u5c0f<br \/>| query_cache_size             | 67108864 |  \u67e5\u8be2\u7f13\u5b58\u603b\u5927\u5c0f<br \/>| query_cache_type             | ON       |  Query Cache \u529f\u80fd\u7684\u5f00\u5173<br \/>| query_cache_wlock_invalidate | OFF      |  \u5f53\u6709\u5176\u4ed6\u5ba2\u6237\u7aef\u6b63\u5728\u5bf9MyISAM\u8868\u8fdb\u884c\u5199\u64cd\u4f5c\u65f6\uff0c\u5982\u679c\u67e5\u8be2\u5728query cache\u4e2d\uff0c\u662f\u5426\u8fd4\u56decache\u7ed3\u679c\u8fd8\u662f\u7b49\u5199\u64cd\u4f5c\u5b8c\u6210\u518d\u8bfb\u8868\u83b7\u53d6\u7ed3\u679c\u3002<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+<\/p>\n<p>\u67e5\u770b\u72b6\u6001<br \/><code>mysql> SHOW STATUS LIKE 'qcache%';<\/code><br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br \/>| Variable_name           | Value    |<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br \/>| Qcache_free_blocks      | 3        |  \u7f13\u5b58\u4e2d\u76f8\u90bb\u5185\u5b58\u5757\u7684\u4e2a\u6570\u3002\u6570\u76ee\u5927\u8bf4\u660e\u53ef\u80fd\u6709\u788e\u7247\u3002FLUSH QUERY CACHE\u4f1a\u5bf9\u7f13\u5b58\u4e2d\u7684\u788e\u7247\u8fdb\u884c\u6574\u7406\uff0c\u4ece\u800c\u5f97\u5230\u4e00\u4e2a\u7a7a\u95f2\u5757\u3002<br \/>| Qcache_free_memory      | 63319944 |  \u7f13\u5b58\u4e2d\u7684\u7a7a\u95f2\u5185\u5b58\u3002<br \/>| Qcache_hits             | 854      |  \u6bcf\u6b21\u67e5\u8be2\u5728\u7f13\u5b58\u4e2d\u547d\u4e2d\u65f6\u5c31\u589e\u5927<br \/>| Qcache_inserts          | 386      |  \u6bcf\u6b21\u63d2\u5165\u4e00\u4e2a\u67e5\u8be2\u65f6\u5c31\u589e\u5927\u3002\u547d\u4e2d\u6b21\u6570\u9664\u4ee5\u63d2\u5165\u6b21\u6570\u5c31\u662f\u4e0d\u4e2d\u6bd4\u7387\u3002<br \/>| Qcache_lowmem_prunes    | 0        |  \u7f13\u5b58\u51fa\u73b0\u5185\u5b58\u4e0d\u8db3\u5e76\u4e14\u5fc5\u987b\u8981\u8fdb\u884c\u6e05\u7406\u4ee5\u4fbf\u4e3a\u66f4\u591a\u67e5\u8be2\u63d0\u4f9b\u7a7a\u95f4\u7684\u6b21\u6570\u3002\u8fd9\u4e2a\u6570\u5b57\u6700\u597d\u957f\u65f6\u95f4\u6765\u770b;\u5982\u679c\u8fd9\u4e2a \u6570\u5b57\u5728\u4e0d\u65ad\u589e\u957f\uff0c\u5c31\u8868\u793a\u53ef\u80fd\u788e\u7247\u975e\u5e38\u4e25\u91cd\uff0c\u6216\u8005\u5185\u5b58\u5f88\u5c11\u3002<br \/>| Qcache_not_cached       | 14       |  \u4e0d\u9002\u5408\u8fdb\u884c\u7f13\u5b58\u7684\u67e5\u8be2\u7684\u6570\u91cf\uff0c\u901a\u5e38\u662f\u7531\u4e8e\u8fd9\u4e9b\u67e5\u8be2\u4e0d\u662f SELECT \u8bed\u53e5\u6216\u8005\u7528\u4e86now()\u4e4b\u7c7b\u7684\u51fd\u6570\u3002<br \/>| Qcache_queries_in_cache | 290      |  \u5f53\u524d\u7f13\u5b58\u7684\u67e5\u8be2(\u548c\u54cd\u5e94)\u7684\u6570\u91cf\u3002<br \/>| Qcache_total_blocks     | 630      |  \u7f13\u5b58\u4e2d\u5757\u7684\u6570\u91cf\u3002<br \/>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<\/p>\n<p>query_cache_min_res_unit\u7684\u914d\u7f6e\u662f\u4e00\u67c4\u201d\u53cc\u5203\u5251\u201d\uff0c\u9ed8\u8ba4\u662f4KB\uff0c\u8bbe\u7f6e\u503c\u5927\u5bf9\u5927\u6570\u636e\u67e5\u8be2\u6709\u597d\u5904\uff0c\u4f46\u5982\u679c\u67e5\u8be2\u90fd\u662f\u5c0f\u6570\u636e\u67e5\u8be2\uff0c\u5c31\u5bb9\u6613\u9020\u6210\u5185\u5b58\u788e\u7247\u548c\u6d6a\u8d39\u3002<\/p>\n<p>\u67e5\u8be2\u7f13\u5b58\u788e\u7247\u7387 = Qcache_free_blocks \/ Qcache_total_blocks * 100%<br \/>\u67e5\u8be2\u7f13\u5b58\u5229\u7528\u7387 = (query_cache_size &#8211; Qcache_free_memory) \/ query_cache_size * 100%<br \/>\u67e5\u8be2\u7f13\u5b58\u547d\u4e2d\u7387 = (Qcache_hits &#8211; Qcache_inserts) \/ Qcache_hits * 100%<\/p>\n<p>\u5982\u679c\u67e5\u8be2\u7f13\u5b58\u788e\u7247\u7387\u8d85\u8fc720%\uff0c\u53ef\u4ee5\u7528FLUSH QUERY CACHE\u6574\u7406\u7f13\u5b58\u788e\u7247\uff0c\u6216\u8005\u8bd5\u8bd5\u51cf\u5c0fquery_cache_min_res_unit\uff0c\u5982\u679c\u67e5\u8be2\u90fd\u662f\u5c0f\u6570\u636e\u91cf\u7684\u8bdd\u3002<br \/>\u67e5\u8be2\u7f13\u5b58\u5229\u7528\u7387\u572825%\u4ee5\u4e0b\u7684\u8bdd\u8bf4\u660equery_cache_size\u8bbe\u7f6e\u7684\u8fc7\u5927\uff0c\u53ef\u9002\u5f53\u51cf\u5c0f;\u67e5\u8be2\u7f13\u5b58\u5229\u7528\u7387\u572880%\u4ee5\u4e0a\u800c\u4e14Qcache_lowmem_prunes > 50\u7684\u8bdd\u8bf4\u660equery_cache_size\u53ef\u80fd\u6709\u70b9\u5c0f\uff0c\u8981\u4e0d\u5c31\u662f\u788e\u7247\u592a\u591a\u3002<br \/>\u793a\u4f8b\u670d\u52a1\u5668 \u67e5\u8be2\u7f13\u5b58\u788e\u7247\u7387 = 20.46%\uff0c\u67e5\u8be2\u7f13\u5b58\u5229\u7528\u7387 = 62.26%\uff0c\u67e5\u8be2\u7f13\u5b58\u547d\u4e2d\u7387 = 1.94%\uff0c\u547d\u4e2d\u7387\u5f88\u5dee\uff0c\u53ef\u80fd\u5199\u64cd\u4f5c\u6bd4\u8f83\u9891\u7e41\u5427\uff0c\u800c\u4e14\u53ef\u80fd\u6709\u4e9b\u788e\u7247\u3002<\/p>\n<p>\u76f8\u5173\u7ecf\u9a8c\uff1a<br \/>\u5982\u679cQcache_lowmem_prunes \u503c\u6bd4\u8f83\u5927\uff0c\u8868\u793a\u67e5\u8be2\u7f13\u5b58\u533a\u5927\u5c0f\u8bbe\u7f6e\u592a\u5c0f\uff0c\u9700\u8981\u589e\u5927\u3002<br \/>\u5982\u679cQcache_free_blocks \u8f83\u591a\uff0c\u8868\u793a\u5185\u5b58\u788e\u7247\u8f83\u591a\uff0c\u9700\u8981\u6e05\u7406\uff0cflush query cache<br \/>\u6839\u636e\u6211\u770b\u7684 \u300aHigh Performance MySQL\u300b\u4e2d\u6240\u8ff0\uff0c\u5173\u4e8equery_cache_min_res_unit\u5927\u5c0f\u7684\u8c03\u4f18<br \/>\uff0c\u4e66\u4e2d\u7ed9\u51fa\u4e86\u4e00\u4e2a\u8ba1\u7b97\u516c\u5f0f\uff0c\u53ef\u4ee5\u4f9b\u8c03\u4f18\u8bbe\u7f6e\u53c2\u8003\uff1a<br \/>query_cache_min_res_unit = (query_cache_size &#8211; Qcache_free_memory) \/ Qcache_queries_in_cache<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u67e5\u770b\u8bbe\u7f6e\uff1amysql> SHOW VARIABLES LIKE &#8216;query_cache%&#8217;;+&#8212; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-2132","post","type-post","status-publish","format-standard","hentry","category-10"],"_links":{"self":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/2132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2132"}],"version-history":[{"count":1,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/2132\/revisions"}],"predecessor-version":[{"id":2133,"href":"https:\/\/www.huzs.top\/index.php?rest_route=\/wp\/v2\/posts\/2132\/revisions\/2133"}],"wp:attachment":[{"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.huzs.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}