{"id":162,"date":"2013-05-29T11:27:13","date_gmt":"2013-05-29T03:27:13","guid":{"rendered":"http:\/\/www.gpfeng.com\/?p=162"},"modified":"2013-08-23T22:53:40","modified_gmt":"2013-08-23T14:53:40","slug":"limit-innodb-dictionary-cache-size","status":"publish","type":"post","link":"http:\/\/www.gpfeng.com\/?p=162","title":{"rendered":"Limit innodb dictionary cache size"},"content":{"rendered":"<h3>\u77e5\u8bc6\u80cc\u666f<\/h3>\n<p>MySQL\u4e2d\u6bcf\u4e2aSELECT\/DML\/DDL\u5728\u6267\u884c\u4e4b\u524d\u9700\u8981\u6253\u5f00\u76f8\u5173\u7684\u8868\uff0c\u6267\u884c\u7ed3\u675f\u540e\u5c06\u5b83\u4eec\u5173\u95ed\uff0c\u4e3a\u4e86\u907f\u514d\u91cd\u590d\u6253\u5f00\/\u5173\u95ed\u7684\u5f00\u9500\uff0cserver\u5c42\u63d0\u4f9b\u4e86table cache\u548ctable definition cache\u7528\u6765\u7f13\u5b58\u6253\u5f00\u7684\u8868\u4fe1\u606f\uff0c\u5728SELECT\/DML\/DDL\u6267\u884c\u4e4b\u524d\u9996\u5148\u4ecetable cache\u4e2d\u53d6\u7a7a\u95f2\u8868\uff0ccache\u4e2d\u6ca1\u6709\u76f8\u5e94\u8868\u624d\u771f\u6b63\u6253\u5f00\u8868\uff0c\u6267\u884c\u7ed3\u675f\u540e\u5c06\u8868\u7f6e\u4e3a\u7a7a\u95f2\u5e76\u653e\u5165\u5230table cache\u4e2d\uff1b\u5173\u4e8e\u8fd9\u90e8\u5206\u7684\u4ee3\u7801\u5206\u6790\u53ef\u4ee5\u53c2\u8003\u4e4b\u524d\u5199\u7684\u4e00\u7bc7<a href=http:\/\/blog.chinaunix.net\/uid-28364803-id-3410671.html>\u535a\u5ba2<\/a>\uff1b\u540c\u65f6\uff0ctable cache\u4e0eMDL\u4e00\u8d77\u63a7\u5236\u8868\u7684\u5e76\u53d1\u8bbf\u95ee\uff0c\u8fd9\u90e8\u5206\u5185\u5bb9\u6253\u7b97\u4e4b\u540e\u603b\u7ed3\u51fa\u4e00\u7bc7\u535a\u5ba2<\/p>\n<p>innodb\u5b9e\u73b0\u4e86dict_sys\uff0c\u5728\u5185\u5b58\u4e2d\u7f13\u5b58\u4e86\u8f7d\u5165\u8fc7\u7684\u8868\u4fe1\u606f\uff0c\u5305\u62ec\u8868\u7684\u5143\u6570\u636e\u4fe1\u606f\uff08\u8868\u540d\uff0cspace\uff0c\u5217\u4fe1\u606f\uff0c\u7d22\u5f15\uff0c\u5916\u952e\u7b49\uff09\uff0c\u8fd8\u5305\u62ec\u8fd0\u884c\u65f6\u7684\u4fe1\u606f\uff08\u6709\u591a\u5c11handler\u6253\u5f00\u4e86\u8be5\u8868\uff0c\u8868\u4e0a\u52a0\u9501\u4fe1\u606f\uff0c\u8fd0\u884c\u65f6\u7edf\u8ba1\u4fe1\u606f\uff09\uff0c\u5177\u4f53\u53ef\u4ee5\u53c2\u8003\u6570\u636e\u7ed3\u6784<strong>dict_table_struct<\/strong><br \/>\n<!--more--><br \/>\ndict_sys\u5728\u5b9e\u73b0\u8fc7\u7a0b\u4e2d\u5e76\u6ca1\u6709\u8003\u8651\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u4e00\u4e2a\u8868\u53ea\u6709\u5728drop\u65f6\u624d\u4f1a\u4ecedictionary cache\u4e2d\u6e05\u9664\uff0c\u4e5f\u8bb8\u662f\u57fa\u4e8e\u8fd9\u6837\u7684\u8003\u8651\uff1a\u4e00\u4e2atable\u5728dictionary cache\u5360\u7528\u7684\u5185\u5b58\u4e0d\u4f1a\u5f88\u5927\uff0810KB\u6570\u91cf\u7ea7\uff08<a href=http:\/\/www.mysqlperformanceblog.com\/2010\/05\/06\/how-much-memory-innodb-dictionary-can-take\/>\u89c1percona\u6d4b\u8bd5<\/a>\uff09\uff0c\u5e94\u8be5\u4e0d\u4f1a\u8d85\u8fc7100KB\uff0c\u548c\u8868\u6a21\u5f0f\u548c\u8fd0\u884c\u65f6\u7cfb\u7edf\u4f7f\u7528\u8be5\u8868\u7684\u60c5\u51b5\u6709\u5173\uff09\uff0c\u56e0\u6b64\u5373\u4f7f\u7cfb\u7edf\u4e2d\u6253\u5f00\u4e8610000\u4e2a\u8868\u6d88\u8017\u7684\u7a7a\u95f4\u4e5f\u4e0d\u4f1a\u8d85\u8fc71G\uff0c\u5bf9\u4e8e\u5927\u5185\u5b58\u8fd0\u884c\u7684innodb\uff0c\u5b8c\u5168\u4e0d\u7528\u5173\u5fc3\u8fd9\u90e8\u5206\u7684\u5f00\u9500\uff0c\u6bd5\u7adf\u8fd9\u70b9\u5b58\u50a8\u5f00\u9500\u5e26\u6765\u7684\u6027\u80fd\u63d0\u5347\u662f\u975e\u5e38\u53ef\u89c2\u7684<\/p>\n<h3>\u5e94\u7528\u9700\u6c42<\/h3>\n<p>\u6709\u4e00\u4e9b\u8f7b\u91cf\u7ea7\u7684\u5e94\u7528\uff0c\u5185\u5b58\u6bd4\u8f83\u7d27\u5f20\uff0c\u5982\u540c\u4e8b\u6709\u8fd9\u6837\u4e00\u4e2a\u9700\u6c42\uff1a\u6570\u636e\u5e93\u6709\u5f88\u591a\u8868\uff0c\u9700\u8981\u7ecf\u5e38\u67e5\u8be2\uff0c\u4f46\u662f\u4ee5embedded server\u8fd0\u884c\uff0c\u5e0c\u671b\u80fd\u591f\u9650\u5236\u5185\u5b58\u4f7f\u7528\uff0c\u8fd9\u65f6innodb dictionary cache\u7684\u8bbe\u8ba1\u5bf9\u4ed6\u4eec\u6765\u8bf4\u5c31\u6709\u4e9b\u201cmemory leak\u201d\u4e86\uff1a\u968f\u7740\u7cfb\u7edf\u8fd0\u884c\uff0c\u6253\u5f00\u7684\u8868\u539f\u6765\u8d8a\u591a\uff0c\u7cfb\u7edf\u5185\u5b58\u6d88\u8017\u8d8a\u6765\u8d8a\u5927\uff0c\u5e76\u4e14innodb dictionary cache\u4e0d\u50cftable cache\u90a3\u6837\u53ef\u4ee5\u901a\u8fc7flush tables\u6765\u91ca\u653e\uff0c\u5b83\u4f1a\u5e38\u9a7b\u5728\u5185\u5b58\u4e2d\u76f4\u5230\u88abdrop<\/p>\n<p>percona\u63d0\u4f9b\u4e86\u4e00\u4e2ainnodb_dict_size_limit\u7684<a href=http:\/\/bazaar.launchpad.net\/~percona-dev\/percona-patches\/dict-size-limit\/revision\/32>patch<\/a>,\u53ef\u4ee5\u6ee1\u8db3\u8fd9\u4e2a\u9700\u6c42\uff1a<\/p>\n<h3>patch\u5b9e\u73b0\u539f\u7406<\/h3>\n<p>1\u3001dict_sys\u4e2d\u7ef4\u62a4\u4e86\u4e00\u4e2atable_LRU\u94fe\u8868\uff0c\u8868\u5934\u662f\u65b0\u8fd1\u8bbf\u95ee\u8fc7\u7684\u8868\uff0c\u8868\u5c3e\u662f\u957f\u65f6\u95f4\u6ca1\u6709\u8bbf\u95ee\u8fc7\u7684\u8868\uff0c\u6bcf\u6b21\u8868\u88ab\u8bbf\u95ee\u540e\u5c06\u8868\u79fb\u5230table_LRU\u5934\u90e8<\/p>\n<p>2\u3001\u589e\u52a0\u53d8\u91cfinnodb_dict_size_limit\u63a7\u5236innodb dictionary cache\u5927\u5c0f\uff0c\u9ed8\u8ba4\u4e3a0\uff0c\u8868\u793a\u4e0d\u9650\u5236<\/p>\n<p>3\u3001\u5728\u6bcf\u6b21\u4ecedict_sys\u83b7\u53d6\u4e00\u4e2adict_table\u540e\uff08\u6bcf\u4e2aSELECT\/DML\/DDL\u6267\u884c\u7684\u65f6\u5019\u90fd\u9700\u8981\u9996\u5148\u6253\u5f00\u8868\uff09\uff0c\u8ba1\u7b97dict_sys\u4f7f\u7528\u7684\u5185\u5b58,\u8ba1\u7b97\u516c\u5f0f\uff1a<\/p>\n<pre lang=\"c\">\r\ndict_sys->table_hash->n_cells + dict_sys->table_id_hash->n_cells)*sizeof(hash_cell_t) + dict_sys->size\r\n<\/pre>\n<p>\u5f53innodb_dict_size_limit\u8bbe\u7f6e\u4e0d\u4e3a0\u65f6\uff0c\u800c\u5f53\u524ddict_sys\u4f7f\u7528\u5185\u5b58\u8d85\u8fc7innodb_dict_size_limit\uff0c\u5c31\u4e0d\u65ad\u4ecetable_LRU\u7684\u5c3e\u90e8\u6dd8\u6c70\u672a\u5728\u4f7f\u7528\u4e2d\u7684\u8868\uff0c\u76f4\u5230dict_sys\u4f7f\u7528\u7684\u5185\u5b58\u4e0d\u8d85\u8fc7innodb_dict_size_limit\u6216\u8005\u4e0d\u80fd\u6dd8\u6c70\uff08\u8868\u90fd\u5728\u4f7f\u7528\u4e2d\uff09<\/p>\n<p>4\u3001\u5bf9\u4e8e\u7cfb\u7edf\u8868\uff0c\u5c06\u5176pin\u5728dictionary cache\u4e2d\uff0c\u4e0d\u80fd\u6dd8\u6c70<\/p>\n<p>\u603b\u7ed3\u548c\u4ecb\u7ecd\u5c31\u5230\u8fd9\u91cc\uff0c\u5177\u4f53\u53c2\u8003<a href=http:\/\/bazaar.launchpad.net\/~percona-dev\/percona-patches\/dict-size-limit\/revision\/32>patch<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u77e5\u8bc6\u80cc\u666f MySQL\u4e2d\u6bcf\u4e2aSELECT\/DML\/DDL\u5728\u6267\u884c\u4e4b\u524d\u9700\u8981\u6253\u5f00\u76f8\u5173\u7684\u8868\uff0c\u6267\u884c\u7ed3\u675f\u540e\u5c06\u5b83\u4eec\u5173\u95ed\uff0c\u4e3a\u4e86\u907f &hellip; <a href=\"http:\/\/www.gpfeng.com\/?p=162\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Limit innodb dictionary cache size<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3tPZp-2C","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/162"}],"collection":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":11,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":395,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/395"}],"wp:attachment":[{"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gpfeng.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}