{"id":86879,"date":"2024-01-10T21:22:03","date_gmt":"2024-01-10T13:22:03","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=86879"},"modified":"2024-01-10T21:22:03","modified_gmt":"2024-01-10T13:22:03","slug":"dba-postgresql-find","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/dba-postgresql-find.html","title":{"rendered":"\u9488\u5bf9DBA\u7684PostgreSQL\u65b0\u53d1\u73b0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u524d\u6bb5\u65f6\u95f4\u65b0\u7684\u91cd\u5927\u7248\u672c\u7684 PostgreSQL 10 \u53d1\u5e03\u4e86\uff01 \u5f3a\u70c8\u5efa\u8bae\u9605\u8bfb\u516c\u544a\u3001\u53d1\u5e03\u8bf4\u660e\u548c\u201c\u65b0\u529f\u80fd\u201d\u6982\u8ff0\u53ef\u4ee5\u5728\u8fd9\u91cc\u3001\u8fd9\u91cc\u548c\u8fd9\u91cc\u3002\u50cf\u5f80\u5e38\u4e00\u6837\uff0c\u5df2\u7ecf\u6709\u76f8\u5f53\u591a\u7684\u535a\u5ba2\u8986\u76d6\u4e86\u6240\u6709\u65b0\u7684\u4e1c\u897f\uff0c\u4f46\u6211\u731c\u6bcf\u4e2a\u4eba\u90fd\u6709\u81ea\u5df1\u8ba4\u4e3a\u91cd\u8981\u7684\u89d2\u5ea6\uff0c\u6240\u4ee5\u4e0e 9.6 \u7248\u4e00\u6837\u6211\u518d\u6b21\u5728\u8fd9\u91cc\u5217\u51fa\u6211\u5370\u8c61\u4e2d\u6700\u6709\u8da3\/\u76f8\u5173\u7684\u529f\u80fd\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u4e0e\u5f80\u5e38\u4e00\u6837\uff0c\u5347\u7ea7\u6216\u521d\u59cb\u5316\u4e00\u4e2a\u65b0\u96c6\u7fa4\u7684\u7528\u6237\u5c06\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\uff08\u4f8b\u5982\uff0c\u66f4\u597d\u7684\u5e76\u884c\u7d22\u5f15\u626b\u63cf\u3001\u5408\u5e76 join \u548c\u4e0d\u76f8\u5173\u7684\u5b50\u67e5\u8be2\uff0c\u66f4\u5feb\u7684\u805a\u5408\u3001\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u66f4\u52a0\u667a\u80fd\u7684 join \u548c\u805a\u5408\uff09\uff0c\u8fd9\u4e9b\u90fd\u5f00\u7bb1\u5373\u7528\uff0c\u4f46\u672c\u6587\u4e2d\u6211\u60f3\u8bb2\u4e00\u4e9b\u4e0d\u80fd\u5f00\u7bb1\u5373\u7528\uff0c\u5b9e\u9645\u4e0a\u4f60\u9700\u8981\u91c7\u53d6\u4e00\u4e9b\u6b65\u9aa4\u624d\u80fd\u4ece\u4e2d\u83b7\u76ca\u7684\u5185\u5bb9\u3002\u4e0b\u9762\u91cd\u70b9\u5c55\u793a\u7684\u529f\u80fd\u662f\u4ece DBA \u7684\u89d2\u5ea6\u6765\u6c47\u7f16\u7684\uff0c\u5f88\u5feb\u4e5f\u6709\u4e00\u7bc7\u6587\u7ae0\u4ece\u5f00\u53d1\u8005\u7684\u89d2\u5ea6\u8bb2\u8ff0\u66f4\u6539\u3002<\/p>\n

\u5347\u7ea7\u6ce8\u610f\u4e8b\u9879<\/strong><\/div>\n

\u9996\u5148\u6709\u4e9b\u4ece\u73b0\u6709\u8bbe\u7f6e\u5347\u7ea7\u7684\u63d0\u793a - \u6709\u4e00\u4e9b\u5c0f\u7684\u4e8b\u60c5\u4f1a\u5bfc\u81f4\u4ece 9.6 \u6216\u66f4\u65e7\u7684\u7248\u672c\u8fc1\u79fb\u65f6\u5f15\u8d77\u95ee\u9898\uff0c\u6240\u4ee5\u5728\u771f\u6b63\u7684\u5347\u7ea7\u4e4b\u524d\uff0c\u4e00\u5b9a\u8981\u5728\u5355\u72ec\u7684\u526f\u672c\u4e0a\u6d4b\u8bd5\u5347\u7ea7\uff0c\u5e76\u904d\u5386\u53d1\u884c\u8bf4\u660e\u4e2d\u6240\u6709\u53ef\u80fd\u7684\u95ee\u9898\u3002\u6700\u503c\u5f97\u6ce8\u610f\u7684\u7f3a\u9677\u662f\uff1a<\/p>\n

\u6240\u6709\u5305\u542b \u201cxlog\u201d \u7684\u51fd\u6570\u90fd\u88ab\u91cd\u547d\u540d\u4e3a\u4f7f\u7528 \u201cwal\u201d \u800c\u4e0d\u662f \u201cxlog\u201d\u3002<\/p>\n

\u540e\u4e00\u4e2a\u547d\u540d\u53ef\u80fd\u4e0e\u6b63\u5e38\u7684\u670d\u52a1\u5668\u65e5\u5fd7\u6df7\u6dc6\uff0c\u56e0\u6b64\u8fd9\u662f\u4e00\u4e2a\u201c\u4ee5\u9632\u4e07\u4e00\u201d\u7684\u66f4\u6539\u3002\u5982\u679c\u4f7f\u7528\u4efb\u4f55\u7b2c\u4e09\u65b9\u5907\u4efd\/\u590d\u5236\/HA \u5de5\u5177\uff0c\u8bf7\u68c0\u67e5\u5b83\u4eec\u662f\u5426\u4e3a\u6700\u65b0\u7248\u672c\u3002<\/p>\n

\u5b58\u653e\u670d\u52a1\u5668\u65e5\u5fd7\uff08\u9519\u8bef\u6d88\u606f\/\u8b66\u544a\u7b49\uff09\u7684 pg_log \u6587\u4ef6\u5939\u5df2\u91cd\u547d\u540d\u4e3a \u201clog\u201d\u3002<\/p>\n

\u786e\u4fdd\u9a8c\u8bc1\u4f60\u7684\u65e5\u5fd7\u89e3\u6790\u6216 grep \u811a\u672c\uff08\u5982\u679c\u6709\uff09\u53ef\u4ee5\u5de5\u4f5c\u3002<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u5c06\u6700\u591a\u4f7f\u7528 2 \u4e2a\u540e\u53f0\u8fdb\u7a0b\u3002<\/p>\n

\u5982\u679c\u5728 CPU \u6570\u91cf\u8f83\u5c11\u7684\u673a\u5668\u4e0a\u5728 postgresql.conf \u8bbe\u7f6e\u4e2d\u4f7f\u7528\u9ed8\u8ba4\u503c 10\uff0c\u5219\u53ef\u80fd\u4f1a\u770b\u5230\u8d44\u6e90\u4f7f\u7528\u7387\u5cf0\u503c\uff0c\u56e0\u4e3a\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5e76\u884c\u5904\u7406\u5df2\u542f\u7528 - \u8fd9\u662f\u4e00\u4ef6\u597d\u4e8b\uff0c\u56e0\u4e3a\u5b83\u5e94\u8be5\u610f\u5473\u7740\u66f4\u5feb\u7684\u67e5\u8be2\u3002\u5982\u679c\u9700\u8981\u65e7\u7684\u884c\u4e3a\uff0c\u8bf7\u5c06 max_parallel_workers_per_gather \u8bbe\u7f6e\u4e3a 0\u3002<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u672c\u5730\u4e3b\u673a\u7684\u590d\u5236\u8fde\u63a5\u5df2\u542f\u7528\u3002<\/p>\n

\u4e3a\u4e86\u7b80\u5316\u6d4b\u8bd5\u7b49\u5de5\u4f5c\uff0c\u672c\u5730\u4e3b\u673a\u548c\u672c\u5730 Unix \u5957\u63a5\u5b57\u590d\u5236\u8fde\u63a5\u73b0\u5728\u5728 pg_hba.conf \u4e2d\u4ee5\u201c\u4fe1\u4efbtrust\u201d\u6a21\u5f0f\u542f\u7528\uff08\u65e0\u5bc6\u7801\uff09\uff01\u56e0\u6b64\uff0c\u5982\u679c\u5176\u4ed6\u975e DBA \u7528\u6237\u4e5f\u53ef\u4ee5\u8bbf\u95ee\u771f\u5b9e\u7684\u751f\u4ea7\u8ba1\u7b97\u673a\uff0c\u8bf7\u786e\u4fdd\u66f4\u6539\u914d\u7f6e\u3002<\/p>\n

\u4ece DBA \u7684\u89d2\u5ea6\u6765\u770b\u6211\u7684\u6700\u7231<\/strong><\/div>\n

\u903b\u8f91\u590d\u5236<\/p>\n

\u8fd9\u4e2a\u671f\u5f85\u5df2\u4e45\u7684\u529f\u80fd\u5728\u4f60\u53ea\u60f3\u8981\u590d\u5236\u4e00\u5f20\u5355\u72ec\u7684\u8868\u3001\u90e8\u5206\u8868\u6216\u8005\u6240\u6709\u8868\u65f6\u53ea\u9700\u8981\u7b80\u5355\u7684\u8bbe\u7f6e\u800c\u6027\u80fd\u635f\u5931\u6700\u5c0f\uff0c\u8fd9\u4e5f\u610f\u5473\u7740\u4e4b\u540e\u4e3b\u8981\u7248\u672c\u53ef\u4ee5\u96f6\u505c\u673a\u5347\u7ea7\uff01\u5386\u53f2\u4e0a\uff08\u9700\u8981 Postgres 9.4+\uff09\uff0c\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u7b2c\u4e09\u65b9\u6269\u5c55\u6216\u7f13\u6162\u7684\u57fa\u4e8e\u89e6\u53d1\u5668\u7684\u89e3\u51b3\u65b9\u6848\u6765\u5b9e\u73b0\u3002\u5bf9\u6211\u800c\u8a00\u8fd9\u662f 10 \u6700\u597d\u7684\u529f\u80fd\u3002<\/p>\n

\u58f0\u660e\u5206\u533a<\/p>\n

\u4ee5\u524d\u7ba1\u7406\u5206\u533a\u7684\u65b9\u6cd5\u901a\u8fc7\u7ee7\u627f\u5e76\u521b\u5efa\u89e6\u53d1\u5668\u6765\u628a\u63d2\u5165\u64cd\u4f5c\u91cd\u65b0\u8def\u7531\u5230\u6b63\u786e\u7684\u8868\u4e2d\uff0c\u8fd9\u4e00\u70b9\u5f88\u70e6\u4eba\uff0c\u66f4\u4e0d\u7528\u8bf4\u6027\u80fd\u7684\u5f71\u54cd\u4e86\u3002\u76ee\u524d\u652f\u6301\u7684\u662f \u201crange\u201d \u548c \u201clist\u201d \u5206\u533a\u65b9\u6848\u3002\u5982\u679c\u6709\u4eba\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u5f15\u64ce\u4e2d\u7f3a\u5c11 \u201c\u54c8\u5e0c\u201d \u5206\u533a\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u5e26\u8868\u8fbe\u5f0f\u7684 \u201clist\u201d \u5206\u533a\u6765\u5b9e\u73b0\u76f8\u540c\u7684\u529f\u80fd\u3002<\/p>\n

\u53ef\u7528\u7684\u54c8\u5e0c\u7d22\u5f15<\/p>\n

\u54c8\u5e0c\u7d22\u5f15\u73b0\u5728\u662f WAL \u8bb0\u5f55\u7684\uff0c\u56e0\u6b64\u662f\u5d29\u6e83\u5b89\u5168\u7684\uff0c\u5e76\u83b7\u5f97\u4e86\u4e00\u4e9b\u6027\u80fd\u6539\u8fdb\uff0c\u5bf9\u4e8e\u7b80\u5355\u7684\u641c\u7d22\uff0c\u5b83\u4eec\u6bd4\u5728\u66f4\u5927\u7684\u6570\u636e\u4e0a\u7684\u6807\u51c6 B \u6811\u7d22\u5f15\u5feb\u3002\u4e5f\u652f\u6301\u66f4\u5927\u7684\u7d22\u5f15\u5927\u5c0f\u3002<\/p>\n

\u8de8\u5217\u4f18\u5316\u5668\u7edf\u8ba1<\/p>\n

\u8fd9\u6837\u7684\u7edf\u8ba1\u6570\u636e\u9700\u8981\u5728\u4e00\u7ec4\u8868\u7684\u5217\u4e0a\u624b\u52a8\u521b\u5efa\uff0c\u4ee5\u6307\u51fa\u8fd9\u4e9b\u503c\u5b9e\u9645\u4e0a\u662f\u4ee5\u67d0\u79cd\u65b9\u5f0f\u76f8\u4e92\u4f9d\u8d56\u7684\u3002\u8fd9\u5c06\u80fd\u591f\u5e94\u5bf9\u8ba1\u5212\u5668\u8ba4\u4e3a\u8fd4\u56de\u7684\u6570\u636e\u5f88\u5c11\uff08\u6982\u7387\u7684\u4e58\u79ef\u901a\u5e38\u4f1a\u4ea7\u751f\u975e\u5e38\u5c0f\u7684\u6570\u5b57\uff09\u4ece\u800c\u5bfc\u81f4\u5728\u5927\u91cf\u6570\u636e\u4e0b\u6027\u80fd\u4e0d\u597d\u7684\u7684\u6162\u67e5\u8be2\u95ee\u9898\uff08\u4f8b\u5982\u9009\u62e9\u201c\u5d4c\u5957\u5faa\u73af\u201d join\uff09\u3002<\/p>\n

\u526f\u672c\u4e0a\u7684\u5e76\u884c\u5feb\u7167<\/p>\n

\u73b0\u5728\u53ef\u4ee5\u5728 pg_dump \u4e2d\u4f7f\u7528\u591a\u4e2a\u8fdb\u7a0b\uff08-jobs \u6807\u5fd7\uff09\u6765\u6781\u5927\u5730\u52a0\u5feb\u5907\u7528\u670d\u52a1\u5668\u4e0a\u7684\u5907\u4efd\u3002<\/p>\n

\u66f4\u597d\u5730\u8c03\u6574\u5e76\u884c\u5904\u7406 worker \u7684\u884c\u4e3a<\/p>\n

\u53c2\u8003 max_parallel_workers \u548c min_parallel_table_scan_size\/min_parallel_index_scan_size \u53c2\u6570\u3002\u6211\u5efa\u8bae\u589e\u52a0\u4e00\u70b9\u540e\u4e24\u8005\u7684\u9ed8\u8ba4\u503c\uff088MB\u3001512KB\uff09\u3002<\/p>\n

\u65b0\u7684\u5185\u7f6e\u76d1\u63a7\u89d2\u8272\uff0c\u4fbf\u4e8e\u5de5\u5177\u4f7f\u7528<\/p>\n

\u65b0\u7684\u89d2\u8272 pg_monitor\u3001pg_read_all_settings\u3001pg_read_all_stats \u548c pg_stat_scan_tables \u80fd\u66f4\u5bb9\u6613\u8fdb\u884c\u5404\u79cd\u76d1\u63a7\u4efb\u52a1 - \u4ee5\u524d\u5fc5\u987b\u4f7f\u7528\u8d85\u7ea7\u7528\u6237\u5e10\u6237\u6216\u4e00\u4e9b SECURITY DEFINER \u5305\u88c5\u51fd\u6570\u3002<\/p>\n

\u7528\u4e8e\u66f4\u5b89\u5168\u7684\u526f\u672c\u751f\u6210\u7684\u4e34\u65f6 (\u6bcf\u4e2a\u4f1a\u8bdd) \u590d\u5236\u69fd<\/p>\n

\u7528\u4e8e\u68c0\u67e5 B \u6811\u7d22\u5f15\u7684\u6709\u6548\u6027\u7684\u4e00\u4e2a\u65b0\u7684 Contrib \u6269\u5c55<\/p>\n

\u8fd9\u4e24\u4e2a\u667a\u80fd\u68c0\u67e5\u53d1\u73b0\u7ed3\u6784\u4e0d\u4e00\u81f4\u548c\u9875\u9762\u7ea7\u6821\u9a8c\u672a\u8986\u76d6\u7684\u5185\u5bb9\u3002\u5e0c\u671b\u4e0d\u4e45\u7684\u5c06\u6765\u80fd\u66f4\u52a0\u6df1\u5165\u3002<\/p>\n

Psql \u67e5\u8be2\u5de5\u5177\u73b0\u5728\u652f\u6301\u57fa\u672c\u5206\u652f\uff08if\/elif\/else\uff09<\/p>\n

\u4f8b\u5982\u4e0b\u9762\u7684\u5c06\u542f\u7528\u5177\u6709\u7279\u5b9a\u7248\u672c\u5206\u652f\uff08\u5bf9 pg_stat* \u89c6\u56fe\u7b49\u6709\u4e0d\u540c\u5217\u540d\uff09\u7684\u5355\u4e2a\u7ef4\u62a4\/\u76d1\u89c6\u811a\u672c\uff0c\u800c\u4e0d\u662f\u8bb8\u591a\u7248\u672c\u7279\u5b9a\u7684\u811a\u672c\u3002<\/p>\n

SELECT :VERSION_NAME = '10.0' AS is_v10 \\gset\r\n\\if :is_v10\r\nSELECT 'yippee' AS msg;\r\n\\else\r\nSELECT 'time to upgrade!' AS msg;\r\n\\endif\r\n<\/pre>\n

\u8fd9\u6b21\u5c31\u8fd9\u6837\u4e86\uff01\u5f53\u7136\u6709\u5f88\u591a\u5176\u4ed6\u7684\u4e1c\u897f\u6ca1\u6709\u5217\u51fa\uff0c\u6240\u4ee5\u5bf9\u4e8e\u4e13\u804c DBA\uff0c\u6211\u4e00\u5b9a\u4f1a\u5efa\u8bae\u4f60\u66f4\u5168\u9762\u5730\u770b\u53d1\u5e03\u8bb0\u5f55\u3002\u975e\u5e38\u611f\u8c22\u90a3 300 \u591a\u4e3a\u8fd9\u4e2a\u7248\u672c\u505a\u51fa\u8d21\u732e\u7684\u4eba\uff01<\/p>\n

via: http:\/\/www.cybertec.at\/best-of-postgresql-10-for-the-dba\/<\/a><\/p>\n

\u4f5c\u8005\uff1aKaarel Moppel<\/a> \u8bd1\u8005\uff1ageekpi<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-9019-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/dba-postgresql-find.html<\/a>\u7f16\u8f91\uff1a\u90d1\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d\/span><\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u524d\u6bb5\u65f6\u95f4\u65b0\u7684\u91cd\u5927\u7248\u672c\u7684 PostgreSQL 10 \u53d1\u5e03\u4e86\uff01 \u5f3a\u70c8\u5efa\u8bae\u9605\u8bfb\u516c\u544a\u3001\u53d1\u5e03\u8bf4\u660e\u548c\u201c\u65b0\u529f\u80fd\u201d\u6982\u8ff0 […]<\/p>\n","protected":false},"author":63,"featured_media":86881,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-86879","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/86879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=86879"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/86879\/revisions"}],"predecessor-version":[{"id":289414,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/86879\/revisions\/289414"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/86881"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=86879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=86879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=86879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}