{"id":5909,"date":"2024-11-14T09:40:04","date_gmt":"2024-11-14T01:40:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5909\/"},"modified":"2024-11-14T09:40:04","modified_gmt":"2024-11-14T01:40:04","slug":"sql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e6%b8%85%e7%90%86%e7%bc%93%e5%ad%98","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5909\/","title":{"rendered":"sql\u6570\u636e\u5e93\u600e\u4e48\u6e05\u7406\u7f13\u5b58"},"content":{"rendered":"<blockquote><p>\n  \u6e05\u7406 sql \u6570\u636e\u5e93\u7f13\u5b58\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684 dbms\uff1amicrosoft sql server\uff1a\u4f7f\u7528 dbcc dropcleanbuffers \u547d\u4ee4\u6216\u5173\u95ed\u548c\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\u3002mysql\uff1a\u4f7f\u7528 flush \u547d\u4ee4\u6216\u66f4\u6539 innodb \u7f13\u51b2\u6c60\u72b6\u6001\u53d8\u91cf\u3002postgresql\uff1a\u4f7f\u7528 vacuum \u547d\u4ee4\u6216 alter system \u547d\u4ee4\u3002oracle\uff1a\u4f7f\u7528 alter system \u547d\u4ee4\u6216 dbms_cache \u5305\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060322100265278.jpg\" class=\"aligncenter\" title=\"sql\u6570\u636e\u5e93\u600e\u4e48\u6e05\u7406\u7f13\u5b58\u63d2\u56fe\" alt=\"sql\u6570\u636e\u5e93\u600e\u4e48\u6e05\u7406\u7f13\u5b58\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u6570\u636e\u5e93\u7f13\u5b58\u6e05\u7406<\/strong><\/p>\n<p><strong>\u5982\u4f55\u6e05\u7406 SQL \u6570\u636e\u5e93\u7f13\u5b58\uff1f<\/strong><\/p>\n<p>\u6e05\u7406 SQL \u6570\u636e\u5e93\u7f13\u5b58\u7684\u8fc7\u7a0b\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684\u7279\u5b9a\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (DBMS)\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u9488\u5bf9\u4e0d\u540c DBMS \u6e05\u7406\u7f13\u5b58\u7684\u6307\u5357\uff1a<\/p>\n<p><strong>Microsoft SQL Server<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 DBCC DROPCLEANBUFFERS \u547d\u4ee4\uff1a<\/strong><\/p>\n<pre>DBCC DROPCLEANBUFFERS<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u5173\u95ed\u548c\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\uff1a<\/strong><\/p>\n<ol>\n<li>\u8fd0\u884c SHUTDOWN WITH NOWAIT \u547d\u4ee4\u5173\u95ed\u6570\u636e\u5e93\u3002<\/li>\n<li>\u7b49\u5f85\u6570\u636e\u5e93\u5b8c\u5168\u5173\u95ed\u3002<\/li>\n<li>\u4f7f\u7528 START \u547d\u4ee4\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>MySQL<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 FLUSH \u547d\u4ee4\uff1a<\/strong><\/p>\n<pre>FLUSH TABLES WITH READ LOCK;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u4f7f\u7528 InnoDB \u7f13\u51b2\u6c60\u72b6\u6001\u53d8\u91cf\uff1a<\/strong><\/p>\n<ol>\n<li>\u8fd0\u884c SHOW INNODB STATUS \u547d\u4ee4\u3002<\/li>\n<li>\u627e\u5230 Buffer Pool \u90e8\u5206\u3002<\/li>\n<li>\u5c06 Buffer Pool Hit Rate \u66f4\u6539\u4e3a 0\uff0c\u7136\u540e\u66f4\u6539\u56de 1\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>PostgreSQL<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 VACUUM \u547d\u4ee4\uff1a<\/strong><\/p>\n<pre>VACUUM FULL;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u4f7f\u7528 ALTER SYSTEM \u547d\u4ee4\uff1a<\/strong><\/p>\n<pre>ALTER SYSTEM RESET ALL;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<\/ol>\n<p><strong>Oracle<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 ALTER SYSTEM \u547d\u4ee4\uff1a<\/strong><\/p>\n<pre>ALTER SYSTEM FLUSH BUFFER_CACHE;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p><strong>\u4f7f\u7528 DBMS_CACHE \u5305\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p>\u5728 PL\/SQL \u4e2d\u521b\u5efa\u4e00\u4e2a\u8fc7\u7a0b\uff1a<\/p>\n<pre>CREATE OR REPLACE PROCEDURE flush_buffer_cache IS\nBEGIN\n  DBMS_CACHE.FLUSH;\nEND;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<li>\n<p>\u6267\u884c\u8be5\u8fc7\u7a0b\uff1a<\/p>\n<pre>CALL flush_buffer_cache;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236  <\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u6267\u884c\u4e0a\u8ff0\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u5907\u4efd\u6570\u636e\u5e93\u4ee5\u786e\u4fdd\u6570\u636e\u5b89\u5168\u3002<\/li>\n<li>\u6e05\u7406\u7f13\u5b58\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\uff0c\u5c24\u5176\u662f\u5728\u6570\u636e\u5e93\u4f7f\u7528\u5927\u91cf\u65f6\u3002<\/li>\n<li>\u5b9a\u671f\u6e05\u7406\u7f13\u5b58\u53ef\u4ee5\u63d0\u9ad8\u6570\u636e\u5e93\u6027\u80fd\u5e76\u91ca\u653e\u5185\u5b58\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u6570\u636e\u5e93\u600e\u4e48\u6e05\u7406\u7f13\u5b58\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6e05\u7406 sql \u6570\u636e\u5e93\u7f13\u5b58\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684 dbms\uff1amicrosoft sql server\uff1a\u4f7f\u7528 dbcc dropcleanbuffers \u547d\u4ee4\u6216\u5173\u95ed\u548c\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\u3002mysql\uff1a\u4f7f\u7528 flush \u547d\u4ee4\u6216\u66f4\u6539 innodb \u7f13\u51b2\u6c60\u72b6\u6001\u53d8\u91cf\u3002postgresql\uff1a\u4f7f\u7528 vacuum \u547d\u4ee4\u6216 alter system \u547d\u4ee4\u3002oracle\uff1a\u4f7f\u7528 alter system \u547d\u4ee4\u6216 dbms_cache \u5305\u3002 SQL \u6570\u636e\u5e93\u7f13\u5b58\u6e05\u7406 \u5982\u4f55\u6e05\u7406 SQL \u6570\u636e\u5e93\u7f13\u5b58\uff1f \u6e05\u7406 SQL \u6570\u636e\u5e93\u7f13\u5b58\u7684\u8fc7\u7a0b\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684\u7279\u5b9a\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (DBMS)\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u9488\u5bf9\u4e0d\u540c DBMS \u6e05\u7406\u7f13\u5b58\u7684\u6307\u5357\uff1a Microsoft SQL Server \u4f7f\u7528 DBCC DROPCLEANBUFFERS \u547d\u4ee4\uff1a DBCC DROPCLEANBUFFERS \u767b\u5f55\u540e\u590d\u5236 \u5173\u95ed\u548c\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\uff1a \u8fd0\u884c SHUTDOWN WITH NOWAIT \u547d\u4ee4\u5173\u95ed\u6570\u636e\u5e93\u3002 \u7b49\u5f85\u6570\u636e\u5e93\u5b8c\u5168\u5173\u95ed\u3002 \u4f7f\u7528 START \u547d\u4ee4\u91cd\u65b0\u6253\u5f00\u6570\u636e\u5e93\u3002 MySQL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5909","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5909"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5909\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}