{"id":167997,"date":"2024-11-06T08:39:23","date_gmt":"2024-11-06T00:39:23","guid":{"rendered":"https:\/\/server.hk\/cnblog\/167997\/"},"modified":"2024-11-06T08:39:24","modified_gmt":"2024-11-06T00:39:24","slug":"%e8%81%8a%e8%81%8apg%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%e6%b8%85%e5%96%ae","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/167997\/","title":{"rendered":"\u804a\u804aPG\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae"},"content":{"rendered":"<h1 id=\"%e8%81%8a%e8%81%8apg%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%e6%b8%85%e5%96%ae-ViPjphrzJP\">\u804a\u804aPG\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae<\/h1>\n<p>\u5728\u4f7f\u7528PostgreSQL\uff08PG\uff09\u8cc7\u6599\u5eab\u6642\uff0c\u4e86\u89e3\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u70ba\u5b83\u80fd\u5e6b\u52a9\u6211\u5011\u8b58\u5225\u548c\u89e3\u6c7a\u6027\u80fd\u74f6\u9838\u3002\u7b49\u5f85\u4e8b\u4ef6\u662f\u6307\u8cc7\u6599\u5eab\u5728\u57f7\u884c\u67e5\u8a62\u6216\u64cd\u4f5c\u6642\uff0c\u56e0\u70ba\u67d0\u4e9b\u8cc7\u6e90\u4e0d\u53ef\u7528\u800c\u66ab\u6642\u505c\u6b62\u7684\u60c5\u6cc1\u3002\u9019\u7bc7\u6587\u7ae0\u5c07\u6df1\u5165\u63a2\u8a0ePG\u7684\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u7bc4\u4f8b\u548c\u5efa\u8b70\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%ef%bc%9f-ViPjphrzJP\">\u4ec0\u9ebc\u662f\u7b49\u5f85\u4e8b\u4ef6\uff1f<\/h2>\n<p>\u7b49\u5f85\u4e8b\u4ef6\u662f\u6307\u8cc7\u6599\u5eab\u5728\u57f7\u884c\u904e\u7a0b\u4e2d\uff0c\u56e0\u70ba\u9700\u8981\u7b49\u5f85\u67d0\u4e9b\u8cc7\u6e90\uff08\u5982\u9396\u3001IO\u64cd\u4f5c\u3001\u7db2\u7d61\u5ef6\u9072\u7b49\uff09\u800c\u66ab\u6642\u505c\u6b62\u7684\u60c5\u6cc1\u3002\u9019\u4e9b\u4e8b\u4ef6\u53ef\u4ee5\u5e6b\u52a9\u8cc7\u6599\u5eab\u7ba1\u7406\u54e1\uff08DBA\uff09\u4e86\u89e3\u7cfb\u7d71\u7684\u6027\u80fd\u72c0\u6cc1\uff0c\u4e26\u627e\u51fa\u6f5b\u5728\u7684\u554f\u984c\u3002<\/p>\n<h2 id=\"postgresql%e7%9a%84%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%e9%a1%9e%e5%9e%8b-ViPjphrzJP\">PostgreSQL\u7684\u7b49\u5f85\u4e8b\u4ef6\u985e\u578b<\/h2>\n<p>PostgreSQL\u7684\u7b49\u5f85\u4e8b\u4ef6\u53ef\u4ee5\u5206\u70ba\u5e7e\u500b\u4e3b\u8981\u985e\u578b\uff1a<\/p>\n<ul>\n<li><strong>\u9396\u7b49\u5f85\uff08Lock Waits\uff09<\/strong>\uff1a\u7576\u4e00\u500b\u4e8b\u52d9\u9700\u8981\u7372\u53d6\u4e00\u500b\u5df2\u88ab\u5176\u4ed6\u4e8b\u52d9\u6301\u6709\u7684\u9396\u6642\uff0c\u5c31\u6703\u767c\u751f\u9396\u7b49\u5f85\u3002<\/li>\n<li><strong>IO\u7b49\u5f85\uff08I\/O Waits\uff09<\/strong>\uff1a\u7576\u8cc7\u6599\u5eab\u9700\u8981\u5f9e\u78c1\u789f\u8b80\u53d6\u6578\u64da\u6642\uff0c\u5982\u679c\u78c1\u789f\u64cd\u4f5c\u5c1a\u672a\u5b8c\u6210\uff0c\u5247\u6703\u767c\u751fIO\u7b49\u5f85\u3002<\/li>\n<li><strong>\u5feb\u53d6\u7b49\u5f85\uff08Buffer Waits\uff09<\/strong>\uff1a\u7576\u8cc7\u6599\u5eab\u9700\u8981\u8a2a\u554f\u5feb\u53d6\u4e2d\u7684\u6578\u64da\uff0c\u4f46\u8a72\u6578\u64da\u5c1a\u672a\u52a0\u8f09\u5230\u5feb\u53d6\u4e2d\u6642\uff0c\u5c31\u6703\u767c\u751f\u5feb\u53d6\u7b49\u5f85\u3002<\/li>\n<li><strong>\u7db2\u7d61\u7b49\u5f85\uff08Network Waits\uff09<\/strong>\uff1a\u7576\u8cc7\u6599\u5eab\u9700\u8981\u7b49\u5f85\u7db2\u7d61\u64cd\u4f5c\u5b8c\u6210\u6642\uff0c\u6703\u51fa\u73fe\u7db2\u7d61\u7b49\u5f85\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%e6%b8%85%e5%96%ae-ViPjphrzJP\">\u5982\u4f55\u67e5\u770b\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae<\/h2>\n<p>\u8981\u67e5\u770bPostgreSQL\u7684\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bSQL\u67e5\u8a62\uff1a<\/p>\n<pre><code>SELECT * FROM pg_stat_activity WHERE state = 'active';<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u6240\u6709\u6d3b\u52d5\u7684\u4e8b\u52d9\uff0c\u5305\u62ec\u5b83\u5011\u7684\u7b49\u5f85\u4e8b\u4ef6\u3002\u4f60\u53ef\u4ee5\u6839\u64da\u9700\u8981\u9032\u4e00\u6b65\u904e\u6ffe\u6216\u6392\u5e8f\u9019\u4e9b\u7d50\u679c\u3002<\/p>\n<h2 id=\"%e5%88%86%e6%9e%90%e7%ad%89%e5%be%85%e4%ba%8b%e4%bb%b6%e7%9a%84%e5%bd%b1%e9%9f%bf-ViPjphrzJP\">\u5206\u6790\u7b49\u5f85\u4e8b\u4ef6\u7684\u5f71\u97ff<\/h2>\n<p>\u4e86\u89e3\u7b49\u5f85\u4e8b\u4ef6\u7684\u5f71\u97ff\u5c0d\u65bc\u512a\u5316\u8cc7\u6599\u5eab\u6027\u80fd\u81f3\u95dc\u91cd\u8981\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u767c\u73fe\u5927\u91cf\u7684\u9396\u7b49\u5f85\uff0c\u9019\u53ef\u80fd\u610f\u5473\u8457\u4f60\u7684\u61c9\u7528\u7a0b\u5f0f\u5728\u540c\u4e00\u6642\u9593\u5167\u5617\u8a66\u8a2a\u554f\u76f8\u540c\u7684\u8cc7\u6e90\uff0c\u5c0e\u81f4\u7af6\u722d\u3002\u9019\u6642\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8003\u616e\u91cd\u69cb\u4f60\u7684\u67e5\u8a62\u6216\u8abf\u6574\u4e8b\u52d9\u7684\u9694\u96e2\u7d1a\u5225\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u5982\u679c\u4f60\u767c\u73feIO\u7b49\u5f85\u7684\u60c5\u6cc1\u8f03\u591a\uff0c\u9019\u53ef\u80fd\u8868\u660e\u4f60\u7684\u78c1\u789f\u6027\u80fd\u4e0d\u8db3\uff0c\u6216\u8005\u8cc7\u6599\u5eab\u7684\u914d\u7f6e\u4e0d\u7576\u3002\u6b64\u6642\uff0c\u53ef\u4ee5\u8003\u616e\u5347\u7d1a\u786c\u9ad4\u6216\u8abf\u6574\u8cc7\u6599\u5eab\u7684\u914d\u7f6e\u53c3\u6578\u3002<\/p>\n<h2 id=\"%e6%9c%80%e4%bd%b3%e5%af%a6%e8%b8%90-ViPjphrzJP\">\u6700\u4f73\u5be6\u8e10<\/h2>\n<p>\u70ba\u4e86\u6709\u6548\u7ba1\u7406\u548c\u6e1b\u5c11\u7b49\u5f85\u4e8b\u4ef6\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u6700\u4f73\u5be6\u8e10\uff1a<\/p>\n<ul>\n<li><strong>\u5b9a\u671f\u76e3\u63a7<\/strong>\uff1a\u4f7f\u7528\u76e3\u63a7\u5de5\u5177\u5b9a\u671f\u6aa2\u67e5\u7b49\u5f85\u4e8b\u4ef6\uff0c\u53ca\u6642\u767c\u73fe\u554f\u984c\u3002<\/li>\n<li><strong>\u512a\u5316\u67e5\u8a62<\/strong>\uff1a\u78ba\u4fdd\u4f60\u7684\u67e5\u8a62\u662f\u9ad8\u6548\u7684\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u9396\u5b9a\u3002<\/li>\n<li><strong>\u8abf\u6574\u914d\u7f6e<\/strong>\uff1a\u6839\u64da\u5be6\u969b\u4f7f\u7528\u60c5\u6cc1\u8abf\u6574PostgreSQL\u7684\u914d\u7f6e\u53c3\u6578\uff0c\u4ee5\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li><strong>\u4f7f\u7528\u9023\u63a5\u6c60<\/strong>\uff1a\u4f7f\u7528\u9023\u63a5\u6c60\u53ef\u4ee5\u6e1b\u5c11\u9023\u63a5\u7684\u958b\u92b7\uff0c\u5f9e\u800c\u964d\u4f4e\u7b49\u5f85\u4e8b\u4ef6\u7684\u767c\u751f\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ViPjphrzJP\">\u7e3d\u7d50<\/h2>\n<p>\u4e86\u89e3PostgreSQL\u7684\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae\u5c0d\u65bc\u7dad\u8b77\u8cc7\u6599\u5eab\u6027\u80fd\u81f3\u95dc\u91cd\u8981\u3002\u900f\u904e\u76e3\u63a7\u548c\u5206\u6790\u7b49\u5f85\u4e8b\u4ef6\uff0c\u8cc7\u6599\u5eab\u7ba1\u7406\u54e1\u53ef\u4ee5\u8b58\u5225\u6027\u80fd\u74f6\u9838\u4e26\u63a1\u53d6\u76f8\u61c9\u7684\u63aa\u65bd\u4f86\u512a\u5316\u7cfb\u7d71\u3002\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u7ba1\u7406\u4f60\u7684\u8cc7\u6599\u5eab\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a>\uff0c\u4ee5\u7372\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u7a69\u5b9a\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22PG\u7b49\u5f85\u4e8b\u4ef6\u6e05\u55ae\uff0c\u4e86\u89e3\u5982\u4f55\u7ba1\u7406\u548c\u512a\u5316\u4e8b\u4ef6\u8655\u7406\uff0c\u63d0\u5347\u7cfb\u7d71\u6548\u80fd\u8207\u7528\u6236\u9ad4\u9a57\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-167997","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/167997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=167997"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/167997\/revisions"}],"predecessor-version":[{"id":167998,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/167997\/revisions\/167998"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=167997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=167997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=167997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}