
https://v2ex.com/t/729909?p=1#reply79
\n" }, { "author": { "url": "member/woodfizky", "name": "woodfizky", "avatar": "https://cdn.v2ex.com/avatar/87a6/dfbc/621021_large.png?m=1774945282" }, "url": "t/1185366", "title": "\u9002\u914d\u4fe1\u521b\u6570\u636e\u5e93\u7684\u4eba\u7684\u7cbe\u795e\u72b6\u6001 be like", "id": "t/1185366", "date_published": "2026-01-13T13:18:32+00:00", "content_html": "\u9002\u914d\u8fc7\u7a0b\u4e2d\u53d1\u73b0\uff1a\u5982\u679c\u67d0\u4e2a SQL \u7684\u67e5\u8be2\u6761\u4ef6\u662f some_col != ''\uff0c\u90a3\u4e48\u8fd4\u56de\u7684\u7ed3\u679c\u5c31\u4f1a\u662f\u7a7a
\n\u4e8e\u662f\u505a\u4e86\u5982\u4e0b\u7b80\u5355\u5b9e\u9a8c\uff1a\nSQL
\nselect\n case\n when ('1' != '') then '1'\n when ('1' = '') then '2'\n else 'else'\n end as result_1,\n ('1' = '')::bool as result_2,\n ('1' != '')::bool as result_3,\n ('1' != '' or '1' = '') as always_true_1,\n ('1' != '1' or '1' = '1') as always_true_2\n\nresult:
\n{\n \"postgres\": {\n \"result_1\": \"2\",\n \"result_2\": false,\n \"result_3\": true,\n \"always_true_1\": true,\n \"always_true_2\": true\n },\n \"gaussdb\": {\n \"result_1\": \"else\",\n \"result_2\": null,\n \"result_3\": null,\n \"always_true_1\": null,\n \"always_true_2\": true\n }\n}\n\n\u5b8c\u5168\u4e0d\u660e\u767d\u4e3a\u4ec0\u4e48 gaussdb \u7684\u903b\u8f91\u662f\u8fd9\u6837\u7684\uff0c\u5982\u679c\u6709\u4eba\u77e5\u9053\u53ef\u4ee5\u544a\u8bc9\u6211\u4e00\u4e0b\u5417\uff1f
\n" }, { "author": { "url": "member/Rooger", "name": "Rooger", "avatar": "https://cdn.v2ex.com/avatar/83db/495c/554382_large.png?m=1752245239" }, "url": "t/1181536", "title": "\u7528\u4e86\u5341\u51e0\u5e74\u7684 MySQL \u4e86\uff0c\u7a81\u7136\u53d1\u73b0 PostgreSQL \u53ef\u80fd\u66f4\u52a0\u9002\u5408\u6211\uff0c\u5927\u5bb6\u600e\u4e48\u770b\uff1f", "id": "t/1181536", "date_published": "2025-12-27T02:54:29+00:00", "content_html": "\u4ece 13 \u5e74\u6bd5\u4e1a\u5f00\u59cb\u5c31\u5f00\u59cb\u4f7f\u7528 MySQL \uff0c\u5f53\u65f6\u4e0d\u7406\u89e3 DBA \u628a\u7528\u6237\u8868\u5206\u6210\u4e86 100 \u5f20\uff0c\u540e\u6765\u5728\u522b\u4eba\u7684\u4e00\u901a\u89e3\u91ca\u4e0b\u4e5f\u6e10\u6e10\u7406\u89e3\u4e86\u3002
\n17 \u5e74\u81ea\u5df1\u5f00\u59cb\u4f5c\u4e3a\u4e3b\u7a0b\u8d1f\u8d23\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u5f53\u65f6\u56e0\u4e3a\u628a\u7528\u6237\u8868\u5206\u6210 100 \u5f20\u8fd8\u8ddf\u8001\u677f\u5435\u8fc7\u67b6\uff08\u56e0\u4e3a\u5f53\u65f6\u53e6\u5916\u4e00\u4e2a\u9879\u76ee\u7684\u8d1f\u8d23\u4eba\u672c\u8eab\u5c31\u662f\u4e2a\u6df7\u6df7\uff0c\u8fd8\u7ed9\u8001\u677f\u4e00\u901a\u4e71\u8bf4\uff0c\u5f04\u7684\u6211\u7279\u522b\u90c1\u95f7\uff0c\u65e0\u5948\u81ea\u5df1\u5f53\u65f6\u7684\u5fc3\u7406\u7d20\u8d28\u4e0d\u662f\u7279\u522b\u5f3a\u5927\uff09\u3002\u540e\u6765\u6211\u4e5f\u89c9\u5f97 100 \u5f20\u8868\u53ef\u80fd\u592a\u591a\u4e86\uff0c\u53ef\u80fd\u6ca1\u6709\u90a3\u4e48\u591a\u7528\u6237\uff0c\u7d22\u6027\u5c31\u53ea\u5206\u4e86\u5341\u5f20\u3002
\n20 \u5e74\u65b0\u7684\u9879\u76ee\uff0c\u5f00\u59cb\u5c1d\u8bd5\u4f7f\u7528 MongoDB \uff0c\u7ecf\u522b\u4eba\u63a8\u8350\uff0c\u8bf4 MongoDB \u600e\u4e48\u9002\u5408\u6e38\u620f\u3002\u5f53\u65f6\u89c9\u5f97\u8fd9\u4e1c\u897f\u597d\u554a\uff0c\u4f46\u662f\u5728\u5b9e\u9645\u4f7f\u7528\u65f6\uff0c\u5e76\u4e0d\u662f\u90a3\u4e48\u7f8e\u597d\u3002
\n24 \u5e74\u53e6\u5916\u4e00\u4e2a\u9879\u76ee\uff0c\u8d1f\u8d23\u4eba\u5168\u90e8\u4f7f\u7528\u4e86 MongoDB \uff0c\u4f46\u662f\u7528\u6cd5\u76f8\u5f53\u66b4\u529b\uff0c\u4e5f\u5c31\u662f\u6bcf\u6b21\u5168\u91cf\u5b58\u50a8\u7528\u6237\u7684\u6570\u91cf\u5230 MongoDB \u4e2d\uff0c\u611f\u89c9\u8ddf\u4f7f\u7528 MySQL \u4e5f\u6ca1\u6709\u4ec0\u4e48\u5b9e\u8d28\u6027\u7684\u533a\u522b\u3002
\n\u4eca\u5e74\u8d1f\u8d23\u53e6\u5916\u4e00\u4e2a\u9879\u76ee\u65f6\uff0c\u6700\u5f00\u59cb\u8bbe\u8ba1\u8005\u5c06\u7528\u6237\u7684 JSON \u6570\u636e\u5148\u8fdb\u884c base64 encode \uff0c\u7136\u540e\u5f02\u6216\u52a0\u5bc6\u5b58\u50a8\u5230\u4e86 MySQL \u4e2d\u3002\u56e0\u4e3a\u6700\u5f00\u59cb\u7684\u5ba2\u6237\u7aef\u7684\u8bbe\u8ba1\u662f\u7eaf\u5355\u673a\uff0c\u540e\u9762\u52a0\u4e86\u670d\u52a1\u5668\u5b58\u50a8\u7528\u6237\u7684\u5b58\u6863\u800c\u5df2\u3002
\n\u65b0\u7684\u9700\u6c42\u662f\u8981\u5c06\u8fd9\u4e2a\u5355\u673a\u7248\u672c\u505a\u6210\u4e00\u4e2a\u8054\u7f51\u7248\u672c\uff0c\u56e0\u4e3a\u6211\u4e4b\u524d\u6709\u5c06\u5355\u673a\u53d8\u6210\u8054\u7f51\u7684\u6210\u529f\u7ecf\u9a8c\uff08\u67d0\u5408\u6210\u6e38\u620f\u53d8\u6210\u8054\u7f51\u7248\u672c\uff0c\u56fd\u5185\u6d41\u6c34\u8fc7\u4e94\u4ebf\uff09\u3002
\n\u73b0\u5728\u7684\u5b58\u50a8\u7ed3\u6784\u6ca1\u6709\u89c4\u5212\u8fc7\uff0cJSON \u7ed3\u6784\u4e0b\u9762\u6709\u8d85\u8fc7 200 \u4e2a\u5b57\u6bb5\uff0c\u6d3b\u52a8\u914d\u7f6e\u5360\u7528\u8d85\u8fc7\u4e86 90% \u7684\u5b58\u50a8\u4ee5\u4e0a\uff0c\u5e73\u5747\u7528\u6237\u7684\u5b58\u50a8\u5360\u7528\u5728 100KB \u4ee5\u4e0a\u3002\n\u5b58\u6863\u4e2d\u5b58\u50a8\u6d3b\u52a8\u914d\u7f6e\u7684\u539f\u56e0\uff1a\u6d3b\u52a8\u5f00\u542f\u4e4b\u540e\uff0c\u5219\u914d\u7f6e\u4e0d\u518d\u53d1\u751f\u53d8\u5316\u3002
\n\u6211\u91cd\u65b0\u8bbe\u8ba1\u4e86\u5b58\u50a8\u7ed3\u6784\uff0c\u4f7f\u7528 Protobuf \u91cd\u65b0\u8bbe\u8ba1\u4e86\u6570\u636e\u5b58\u50a8\uff0c\u5c06\u6d3b\u52a8\u914d\u7f6e\u6570\u636e\u8ddf\u6e38\u620f\u5b58\u6863\u5206\u79bb\u3002\u6d3b\u52a8\u914d\u7f6e\u5355\u72ec\u5b58\u6863\u5728\u4e00\u5f20\u914d\u7f6e\u8868\uff0c\u7528\u6237\u7684\u5b58\u50a8\u4e2d\u53ea\u8bb0\u5f55\u5bf9\u5e94\u7684\u552f\u4e00 ID \u3002\u540c\u65f6\u63d0\u4f9b\u4e86\u63a5\u53e3\uff0c\u53ef\u80fd\u5c06\u65e7\u7684\u6570\u636e\u8f6c\u6362\u4e3a\u65b0\u7684 Protobuf \u5b58\u50a8\u7ed3\u6784\u3002
\n\u7528\u6237\u7684\u6570\u636e\u5b58\u50a8\u4e2d\uff0c\u4f7f\u7528 JSON \u5b58\u50a8\uff0c\u5b58\u50a8\u7684\u5185\u5bb9\u4e3a Protobuf \u5bf9\u5e94\u7684 JSON \u6570\u636e\u3002\u7528\u6237\u66f4\u65b0\u6570\u636e\u65f6\uff0c\u63d0\u4f9b\u4e86 FieldMask \u4ec5\u4fee\u6539\u90e8\u5206\u6570\u636e\uff08\u53ea\u524d\u6bcf\u6b21\u90fd\u662f\u5168\u91cf\u66f4\u65b0\uff09\u3002
\n\u5f53\u8fd9\u4e2a\u7248\u672c\u6210\u529f\u4e0a\u7ebf\u4e4b\u540e\uff0c\u6211\u53d1\u73b0\u67d0\u4e9b\u63a5\u53e3\u8c03\u7528\u6bd4\u8f83\u6162\uff0c\u4f8b\u5982\u5728\u7528\u6237\u8f6c\u6362\u5b58\u6863\u65f6\uff0c\u6211\u5c06\u5ba2\u6237\u7aef\u63d0\u4f9b\u7684\u539f\u59cb\u6570\u636e\u3001\u8f6c\u6362\u4e4b\u540e\u7684\u7ed3\u679c\u5b58\u50a8\u5230\u4e86 conversion_logs \u914d\u7f6e\u8868\uff08\u6570\u636e\u7c7b\u578b\u5747\u4e3a JSON \uff09\uff0c\u5185\u7f51\u7684\u865a\u62df\u673a\u4e0a\u5e73\u5747\u8017\u65f6\u4e3a 200ms \u3002\u56e0\u4e3a\u6700\u8fd1\u5728\u7814\u7a76 PostgreSQL \uff0c\u7d22\u6027\u5c31\u8bd5\u4e86\u4e00\u4e0b\u6027\u80fd\u5bf9\u6bd4\uff0c\u7ed3\u679c PG \u53ea\u9700\u8981 20ms \u5de6\u53f3\u3002\u6700\u5173\u952e\u7684\u662f\uff0c\u8868\u7a7a\u95f4\u5b58\u50a8\u7684\u5360\u7528\u4e0a\uff0cPG \u8fdc\u4f4e\u4e8e MySQL \uff0c\u56e0\u4e3a PG \u5b58\u50a8\u4f7f\u7528\u7684\u7c7b\u578b\u4e3a JSONB \u3002
\u6211\u5c1d\u8bd5\u5bf9\u6bd4\u7eaf TEXT \u5b57\u6bb5\u7684\u8bb0\u5f55\u65f6\uff0cPG \u5360\u7528\u7684\u7a7a\u95f4\u4e5f\u53ea\u6709 MySQL \u7684 1/3 \uff0c\u73b0\u5728\u7684\u6570\u636e\u8868\u73b0\u5c31\u662f\u5728\u5b58\u50a8\u548c\u63d2\u5165\u901f\u5ea6 MySQL \u8fdc\u4f4e\u4e8e PG \u3002\u66f4\u65b0\u7684\u901f\u5ea6\u8fd8\u6ca1\u6709\u5b8c\u5168\u9a8c\u8bc1\u3002
\nSELECT\n table_name,\n ROUND((data_length + index_length) / 1024 / 1024, 2) AS total_mb,\n ROUND(data_length / 1024 / 1024, 2) AS data_mb,\n ROUND(index_length / 1024 / 1024, 2) AS index_mb\nFROM information_schema.tables\nWHERE table_schema = 'merge_island'\n AND table_name IN ('conversion_logs','game_saves','activity_saves','activity_config');\n \n+-----------------+----------+---------+----------+\n| TABLE_NAME | total_mb | data_mb | index_mb |\n+-----------------+----------+---------+----------+\n| activity_config | 216.83 | 209.55 | 7.28 |\n| activity_saves | 0.16 | 0.16 | 0.00 |\n| conversion_logs | 70.55 | 70.52 | 0.03 |\n| game_saves | 7.48 | 7.39 | 0.09 |\n+-----------------+----------+---------+----------+\n\nSELECT\n relname AS table_name,\n pg_size_pretty(pg_total_relation_size(relid)) AS total_size\nFROM pg_catalog.pg_statio_user_tables\nWHERE relname IN ('conversion_logs','game_saves','activity_saves','activity_config');\ntable_name | total_size\n-----------------+------------\n activity_config | 32 MB\n activity_saves | 376 kB\n conversion_logs | 13 MB\n game_saves | 1976 kB\n\n\u53e6\u5916\u628a\u7528\u6237\u5206\u4e3a 100 \u5f20\u7684\u64cd\u4f5c\u5728 PG \u8fd9\u91cc\u5b8c\u5168\u662f\u53cd\u6a21\u5f0f\u7684\uff0c\u56e0\u4e3a PG \u53f7\u79f0\u5355\u8868\u8f7b\u677e\u8fc7\u4ebf\u3002\u53e6\u5916\u5341\u591a\u5e74\u524d\u7684\u8001\u8bbe\u8ba1\u672c\u5e94\u8be5\u4e5f\u8981\u88ab\u6dd8\u6c70\u4e86\uff0c\u6bd5\u7adf\u73b0\u5728\u90fd\u662f\u4e91\u670d\u52a1\uff0c\u7a7a\u95f4\u5b58\u50a8\u53ef\u4ee5\u8f7b\u677e\u6269\u5145\uff0c\u4e0d\u7528\u518d\u62c5\u5fc3\u8fd9\u4e2a\u95ee\u9898\u3002
\n\u6709\u6ca1\u6709\u4f7f\u7528 PG \u6dd8\u6c70 MySQL \u7684\u5927\u4f6c\u6765\u5206\u4eab\u4e00\u4e0b\u81ea\u5df1\u7684\u7ecf\u5386\uff0c\u4e00\u8d77\u5b66\u4e60\u54c8\u3002
\n" }, { "author": { "url": "member/YanSeven", "name": "YanSeven", "avatar": "https://cdn.v2ex.com/avatar/3f22/feff/383743_large.png?m=1775465214" }, "url": "t/1179663", "date_modified": "2025-12-18T02:35:57+00:00", "content_html": "pg \u662f\u591a\u8fdb\u7a0b\u6a21\u578b\u7684\uff0c\u90a3\u4e48\u6211\u6709\u5982\u4e0b\u51e0\u4e2a\u95ee\u9898\uff1a\u7b2c\u4e00\u952e\uff0c\u5728\u7b2c\u4e00\u4e2a vps \u91cc\u5b89\u88c5\u8fd9\u4e2a https://github.com/node-pulse/admiral
\n\u6709\u4e00\u4e2a\u4e00\u952e\u811a\u672c\uff0c\u53bb release \u91cc\u53ef\u4ee5\u4e0b\u8f7d
\n\u8fd9\u4e2a\u5e73\u53f0\u53ef\u4ee5\u505a\u670d\u52a1\u5668\u76d1\u63a7\uff0c\u53ef\u4ee5\u505a ansible \u81ea\u52a8\u5316\u90e8\u7f72
\n\u7b2c\u4e8c\u952e\uff0c\u5c31\u662f\u53bb\u793e\u533a\u5267\u672c\u91cc\u627e\u5230\u8fd9\u4e2a \uff1aPostgreSQL Stack (PostgreSQL + PostgREST + pgweb + Nginx)
\n\u7136\u540e\u4e0b\u8f7d
\n\u6700\u540e\u4e00\u6b65\u5c31\u662f\u90e8\u7f72\u5230\u7b2c\u4e8c\u4e2a vps
\n\u6240\u4ee5\u4f60\u9700\u8981 2 \u4e2a vps
\n\u8fd9\u4e2a pg \u670d\u52a1\u5305\u542b
\n\u5982\u679c\u4f60\u53ea\u6709\u4e00\u4e2a vps
\n\u53ef\u4ee5\u7528 ansible \u547d\u4ee4\u884c\uff0c\u91cc\u9762\u9700\u8981 3 \u4e2a\u53c2\u6570\uff1a
\nansible-playbook install.yml -i inventory \\\n -e domain=db.example.com \\\n -e admin_email=you@example.com \\\n -e authelia_admin_password=YourSecurePass123\n\n", "date_published": "2025-11-30T01:37:40+00:00", "title": "\u4e8c\u952e\u5b89\u88c5\u4e00\u4e2a postgresql \u670d\u52a1", "id": "t/1175897" }, { "author": { "url": "member/shendaowu", "name": "shendaowu", "avatar": "https://cdn.v2ex.com/avatar/6fa4/0f0c/233858_large.png?m=1771487434" }, "url": "t/1175308", "date_modified": "2025-11-27T00:33:17+00:00", "content_html": "\u6211\u95ee\u4e86 DeepSeek \uff0c\u5b83\u8bf4 roaringbitmap \u7c7b\u578b\u7684\u503c\u7684\u5143\u7d20\u7684\u53d6\u503c\u8303\u56f4\u5982\u679c\u5f88\u5927\u7684\u8bdd\u4f1a\u5f71\u54cd\u6548\u7387\u3002\u5c31\u662f\u7c7b\u4f3c INSERT INTO tag_content_bitmaps (tag_id, content_bitmap) VALUES(1, rb_build(ARRAY[1,100000])) \u7684\u5185\u5bb9\u67e5\u8be2\u6548\u7387\u4f1a\u4f4e\u4e8e INSERT INTO tag_content_bitmaps (tag_id, content_bitmap) VALUES(1, rb_build(ARRAY[1,2])) \u3002\u7136\u540e\u6211\u5c31\u60f3\u5230\u4e86\u4e00\u4e9b\u82b1\u6d3b\u3002\u5982\u9898\uff0c\u65b0\u624b\u63a5\u89e6 TimescaleDB \uff0c\u76ee\u524d\u662f\u7528\u8fd9\u5957\u65b9\u6848\u505a\u4e86\u4e00\u5957\u5b58\u97f3\u9891\u4f20\u611f\u5668\u7684\u6570\u636e\u7684\u5de5\u5177\uff0c\u5927\u6982\u6709 100 \u4e2a\u5de6\u53f3\u7684\u4f20\u611f\u5668\uff0c\u5b58\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u65e5\u589e\u5927\u6982\u5341\u4e07\u884c\u5de6\u53f3\u3002
\n\u76ee\u524d\u9047\u5230\u6bd4\u8f83\u5927\u4e00\u4e2a\u95ee\u9898\u662f\uff0c\u5e38\u89c1\u7684\u641c\u7d22\u573a\u666f\u662f\u201c\u641c\u7d22\u4f20\u611f\u5668 A \u5728\u67d0\u6708\u67d0\u65e5\u5230\u67d0\u6708\u67d0\u65e5\u671f\u95f4\u7684\u6240\u6709\u8bb0\u5f55\u201d\u3002\u4f46\u662f\u76ee\u524d\u641c\u7d22\u4f18\u5316\u5668\u662f\u5148\u4ece\u65f6\u95f4\u7684\u603b\u5e8f\u5217\u5f00\u59cb\u67e5\uff0c\u7136\u540e\u518d\u7b5b\u9009\u5176\u4e2d\u7684 A \u4f20\u611f\u5668\u3002\u800c\u6211\u89c9\u5f97\u903b\u8f91\u4e0a\u663e\u7136\u662f\u5148\u641c\u7d22 A \u4f20\u611f\u5668\u518d\u7b5b\u9009\u65f6\u95f4\u66f4\u4f18\u3002
\n\u524d\u8005\u4e0d\u5149\u662f\u6162\u7684\u95ee\u9898\uff0c\u800c\u4e14\u73b0\u5728\u6709\u4e2a\u5927\u95ee\u9898\u662f\u8d70\u65f6\u95f4\u7d22\u5f15\u7684\u8bdd\uff0c\u6bcf\u4e2a\u64cd\u4f5c\u5360\u7528\u9501\u7684\u6570\u91cf\u592a\u591a\u4e86\uff0c\u5c31\u7b97\u628a\u53c2\u6570\u8c03\u5927\u4e86\uff0c\u65e5\u5e38\u4f7f\u7528\u4e5f\u7ecf\u5e38\u62a5\u9519\u3002
\n\u95ee\u4e0b\u4e07\u80fd\u7684 v2 \uff0c\u6709\u4ec0\u4e48\u529e\u6cd5\u89e3\u51b3\u5417\uff1f
\n\u9644\uff1a\n\u521b\u5efa\u8868\u7684\u547d\u4ee4\uff1a
\nCREATE TABLE sensor_data (\n ts TIMESTAMPTZ NOT NULL,\n sensor_id INTEGER NOT NULL,\n data VARCHAR(64) NOT NULL,\n\n PRIMARY KEY (sensor_id, ts)\n);\n\nSELECT create_hypertable(\n 'sensor_data',\n 'ts',\n partitioning_column => 'sensor_id',\n number_partitiOns=> 16, \n chunk_time_interval => INTERVAL '7 day' \n);\n\n\u89e3\u91ca\u641c\u7d22\u547d\u4ee4\u5f97\u5230\u5982\u4e0b\u7ed3\u679c\uff1a
\nEXPLAIN (ANALYZE, BUFFERS)\nSELECT * FROM sensor_data\nWHERE sensor_id = '001'\n AND ts >= '2024-12-06 00:00:00+08'::timestamptz\n AND ts < '2024-12-07 00:00:00+08'::timestamptz;\n\n\n QUERY PLAN \n\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n Index Scan using _hyper_3_23024_chunk_sensor_data_ts_idx on _hyper_3_23024_chunk (cost=0.28..6.71 rows=144 width=45) (actual time=0.032..0.062 rows=144 loops=1)\n Index Cond: ((ts >= '2024-12-06 00:00:00+08'::timestamp with time zone) AND (ts < '2024-12-07 00:00:00+08'::timestamp with time zone))\n Filter: (sensor_id = 1)\n Buffers: shared hit=6\n Planning:\n Buffers: shared hit=1076 read=1\n Planning Time: 7.689 ms\n Execution Time: 11.201 ms\n(8 rows)\n\n\n\n\u5982\u5404\u4f4d\u6240\u89c1\u7684\u5c31\u662f\u4e0d\u7ba1\u600e\u4e48\u8c03\uff0c\u4e00\u5f00\u59cb\u90fd\u662f\u8d70 ts_idx \u7d22\u5f15\uff0c\u7136\u540e\u518d filter sensor_id
\n\u611f\u89c9 timescaleDB \u662f\u4e2a\u597d\u4e1c\u897f\uff0c\u4f46\u662f\u8fd9\u4e2a\u95ee\u9898\u5361\u4f4f\u5b8c\u5168\u6ca1\u6cd5\u7528\u554a\u3002\u62dc\u8c22\u5404\u4f4d
\n", "date_published": "2025-11-08T01:44:45+00:00", "title": "PostgreSQL + TimescaleDB \u65b9\u6848\u4e0d\u6309\u4e3b\u952e\u7d22\u5f15\u8d70\uff0c\u6709\u4ec0\u4e48\u529e\u6cd5\u5417\uff1f", "id": "t/1171344" }, { "author": { "url": "member/anivie", "name": "anivie", "avatar": "https://cdn.v2ex.com/avatar/5aa1/52a3/628407_large.png?m=1773838354" }, "url": "t/1167813", "date_modified": "2025-10-23T04:20:51+00:00", "content_html": "\u4e00\u76f4\u628a mysql \u5f53\u5927\u53f7 excel \u7528\uff0c\u6700\u8fd1\u5f00\u4e86\u4e2a\u65b0\u5751\uff0c\u76f4\u63a5\u4e0a\u4e86 pg \uff0c\u8ba9 AI \u6765\u6307\u5bfc\u6570\u636e\u5e93\u7ba1\u7406\uff0c\u4f46\u662f\u6ca1\u4ec0\u4e48\u7ecf\u9a8c\u4e0d\u77e5\u9053 AI \u7684\u5efa\u8bae\u8be5\u4e0d\u8be5\u9075\u5faa\u5982\u9898\uff0c\u5927\u6982\u6bcf\u4e2a\u4e3b\u6761\u76ee\u4e0b\u9762\u5173\u8054\u6709\u51e0\u5f20\u5230\u4e00\u4e24\u767e\u5f20\u4e0d\u7b49\u7684\u56fe\u7247/\u6587\u6863\u4e4b\u7c7b\u7684\u9644\u4ef6\uff0c\u6bcf\u5f20\u56fe\u6700\u5927 500KB \uff08\u5165\u5e93\u65f6\u8d85\u5927\u4f1a\u81ea\u52a8\u538b\u7f29\uff09\uff0c\u6587\u6863\u4e5f\u662f\u4e0d\u8d85\u8fc7 500KB \u3002
\n\u76ee\u524d\u6d4b\u8bd5\u6570\u636e\uff08\u51e0\u5341/\u767e\u6765\u4e2a\u4e3b\u6761\u76ee\uff09\u8dd1\u8d77\u6765\u611f\u89c9\u633a\u9999\u7684\uff0c\u4e5f\u6ca1\u89c1\u4ec0\u4e48\u6027\u80fd\u95ee\u9898\u3002\u7279\u522b\u662f\u8bbe\u7f6e\u597d\u5916\u952e\u548c cascade delete \u4e4b\u540e\uff0c\u4e3b\u6761\u76ee\u5220\u9664\u4f1a\u81ea\u52a8\u628a\u5b58 binary \u7684\u8868\u4e2d\u5173\u8054\u7684\u9644\u4ef6\u4e00\u5e76\u5e72\u6389\uff0c\u6bd4\u653e\u6587\u4ef6\u7cfb\u7edf\u597d\u7ef4\u62a4\u3002\u6587\u4ef6\u7cfb\u7edf\u8fd8\u8981\u81ea\u5df1\u5904\u7406\u6570\u636e\u5173\u8054\u548c\u6e05\u7406\u903b\u8f91\u3002
\n\u5c31\u662f\u4e0d\u77e5\u9053\u4ee5\u540e\u6570\u636e\u91cf\u5927\u4e86\u4f1a\u6709\u4ec0\u4e48\u5751\uff0c\u9884\u8ba1\u4e4b\u540e\u4e3b\u6761\u76ee\u6709\u6570\u4e07\u4e2a\u8fd9\u6837\u7684\u91cf\u7ea7\u3002
\n", "date_published": "2025-09-23T08:08:29+00:00", "title": "\u7528 PostgreSQL \u5b58\u56fe\u7247\u7b49 binary \u6709\u4ec0\u4e48\u5751\u5417", "id": "t/1161291" }, { "author": { "url": "member/Apol1oBelvedere", "name": "Apol1oBelvedere", "avatar": "https://cdn.v2ex.com/avatar/3eaa/16c7/380208_large.png?m=1760590534" }, "url": "t/1156030", "title": "[\u6c42\u52a9] \u5728\u54ea\u4e2a\u7f51\u5740\u80fd\u591f\u4e0b\u8f7d PostgresSQL 9.3.0 \u7248\u672c\u7684 Windows \u4e8c\u8fdb\u5236\u5b89\u88c5\u5305\uff1f\u5b98\u65b9/ftp/old/binary \u91cc\u6ca1\u6709\u3002", "id": "t/1156030", "date_published": "2025-08-31T02:42:11+00:00", "content_html": "[\u6c42\u52a9] \u5728\u54ea\u4e2a\u7f51\u5740\u80fd\u591f\u4e0b\u8f7d PostgresSQL 9.3.0 \u7248\u672c\u7684 Windows \u4e8c\u8fdb\u5236\u5b89\u88c5\u5305\uff1fhnsw\uff0c\u5411\u91cf\u7c7b\u578bhalfvec\uff0cm\u53d6 16 \uff0cef_construction\u4e3a 100 \uff0c\u8ddd\u79bb\u8ba1\u7b97L2 distance\u3002asyncpg\uff0c\u5373\u57fa\u4e8e Python \u5f02\u6b65 IO \u7684\u9a71\u52a8\u3002\u4f7f\u7528 48 \u4e2a\u4e0d\u540c\u5206\u7c7b\u7684\u5411\u91cf\uff0c\u5206\u522b\u641c\u7d22\u5bf9\u5e94\u5206\u7c7b\u7684\u76f8\u4f3c\u5546\u54c1\u5411\u91cf\u3002\u5f02\u6b65 IO \u540c\u65f6\u53d1\u9001 48 \u4e2a\u67e5\u8be2\u5411\u91cf\u7684 SQL \u65f6,\u67e5\u8be2\u5f88\u6162\uff0c\u7ea6 700ms~1600ms \uff0c\u800c\u4e14 48 \u4e2a\u67e5\u8be2\u51e0\u4e4e\u540c\u65f6\u8fd4\u56de\u3002
\n\u6539\u4e3a\u6bcf\u6b21\u540c\u65f6\u53d1\u9001 4 \u4e2a\u67e5\u8be2\uff0c\u7ea6 200ms \u5b8c\u6210 48 \u4e2a\u67e5\u8be2\u3002
\n\u5404\u4f4d\u6570\u636e\u5e93\u4e13\u5bb6\u597d\uff0c\n\u6211\u76ee\u524d\u5728\u5f00\u53d1\u4e00\u4e2a\u7cfb\u7edf\uff0c\u5176\u4e2d\u6709\u4e00\u4e2a\u7279\u6b8a\u7684\u6570\u636e\u540c\u6b65\u573a\u666f\u9700\u8981\u5bfb\u6c42\u5efa\u8bae\u3002\n\u7cfb\u7edf\u67b6\u6784\u5982\u4e0b\uff1a
\n1 \u4e2a\u4e2d\u592e\u4e3b\u6570\u636e\u5e93\uff08 PostgreSQL \uff09\nN \u53f0\u7b14\u8bb0\u672c\u7535\u8111\uff0c\u6bcf\u53f0\u90fd\u5b89\u88c5\u4e86\u672c\u5730 PostgreSQL \u6570\u636e\u5e93\n\u7b14\u8bb0\u672c\u7535\u8111\u53ef\u80fd\u4f1a\u79bb\u7ebf\u5de5\u4f5c\uff0c\u6bcf\u5929\u90fd\u4f1a\u4ea7\u751f\u65b0\u8bb0\u5f55\n\u7b14\u8bb0\u672c\u9700\u8981\u5b9a\u671f\u4e0e\u4e3b\u6570\u636e\u5e93\u8fdb\u884c\u53cc\u5411\u540c\u6b65
\n\u6211\u73b0\u5728\u9762\u4e34\u4e00\u4e2a\u4e3b\u952e\u8bbe\u8ba1\u7684\u9009\u62e9\u95ee\u9898\uff1a\u662f\u4f7f\u7528 UUID \u4f5c\u4e3a\u4e3b\u952e\uff0c\u8fd8\u662f\u7ee7\u7eed\u4f7f\u7528\u81ea\u589e ID \uff1f\n\u6211\u7684\u521d\u6b65\u60f3\u6cd5\u662f\u4f7f\u7528 UUID \u53ef\u80fd\u66f4\u5408\u9002\uff0c\u56e0\u4e3a\uff1a
\n\u6bcf\u53f0\u7b14\u8bb0\u672c\u53ef\u4ee5\u72ec\u7acb\u751f\u6210\u5168\u5c40\u552f\u4e00 ID \uff0c\u4e0d\u4f1a\u4e0e\u5176\u4ed6\u8bbe\u5907\u4ea7\u751f\u51b2\u7a81\n\u540c\u6b65\u65f6\u4e0d\u9700\u8981\u5904\u7406\u4e3b\u952e\u51b2\u7a81\u95ee\u9898\n\u4e0d\u9700\u8981\u590d\u6742\u7684\u4e3b\u952e\u6620\u5c04\u6216\u8f6c\u6362\u673a\u5236
\n\u800c\u5982\u679c\u4f7f\u7528\u81ea\u589e ID \uff0c\u6211\u62c5\u5fc3\u4f1a\u9047\u5230\u4ee5\u4e0b\u95ee\u9898\uff1a
\n\u6bcf\u53f0\u7b14\u8bb0\u672c\u751f\u6210\u7684\u81ea\u589e ID \u4f1a\u91cd\u590d\n\u540c\u6b65\u65f6\u9700\u8981\u89e3\u51b3 ID \u51b2\u7a81\n\u53ef\u80fd\u9700\u8981\u989d\u5916\u7684 ID \u6620\u5c04\u8868
\n\u8bf7\u95ee\u5404\u4f4d\u6709\u6ca1\u6709\u5904\u7406\u8fc7\u7c7b\u4f3c\u7684\u5206\u5e03\u5f0f\u6570\u636e\u5e93\u540c\u6b65\u573a\u666f\uff1f UUID \u662f\u5426\u786e\u5b9e\u662f\u66f4\u597d\u7684\u9009\u62e9\uff1f\u6216\u8005\u6709\u5176\u4ed6\u66f4\u4f18\u65b9\u6848\uff1f\u5728\u6027\u80fd\u3001\u5b58\u50a8\u7a7a\u95f4\u548c\u540c\u6b65\u590d\u6742\u5ea6\u4e4b\u95f4\uff0c\u5982\u4f55\u505a\u51fa\u6743\u8861\uff1f\n\u611f\u8c22\u5206\u4eab\u60a8\u7684\u7ecf\u9a8c\u548c\u5efa\u8bae\uff01
\n", "date_published": "2025-04-17T09:34:38+00:00", "title": "\u591a\u7b14\u8bb0\u672c\u79bb\u7ebf PostgreSQL \u6570\u636e\u5e93\u540c\u6b65\u95ee\u9898\uff1a UUID vs \u81ea\u589e\u4e3b\u952e", "id": "t/1126245" }, { "author": { "url": "member/annoygaga", "name": "annoygaga", "avatar": "https://cdn.v2ex.com/avatar/4a2c/bdb6/227146_large.png?m=1721825554" }, "url": "t/1124891", "date_modified": "2025-04-11T23:52:34+00:00", "content_html": "\u5982\u9898\uff0c\u76ee\u524d\u6709\u6709\u9700\u6c42\u5e0c\u671b\u80fd\u591f\u7ed9\u7528\u6237\u5f00\u653e\u4e00\u4e2a SQL \u6570\u636e\u5e93\uff0c\u5f00\u653e SQL \u80fd\u529b\uff08 SaaS \u573a\u666f\u9700\u6c42\uff09\uff0c\u4e0d\u7136\u81ea\u5df1\u5c01\u88c5 SQL \u96be\u53d7\uff0c\u7528\u6237\u4e5f\u96be\u53d7\u3002
\n\u5c0f\u5f1f\u5bf9 postgresql \u4e4b\u524d\u53ea\u6709\u4f7f\u7528\u7ecf\u9a8c\uff0c\u5bf9\u5176 user/database/\u6743\u9650\u80fd\u529b\u4e86\u89e3\u4e0d\u591a\uff0c\u7279\u6765\u95ee\u95ee
\nchatgpt \u63a8\u8350\uff1a\u4e00\u4e2a PG \u5b9e\u4f8b\uff0cN \u4e2a\u7528\u6237\uff0c\u901a\u8fc7\u4e0d\u540c\u7684 database \u548c user \u8fdb\u884c\u9694\u79bb\uff0c\u524d\u9762\u4e00\u4e2a\u8fde\u63a5\u6c60\u4fdd\u8bc1\u4e00\u4e2a user \u53ea\u80fd\u8fde\u63a5\u67d0\u4e2a database
\n\u6211\u60f3\u95ee\u95ee\u8fd9\u4e2a\u65b9\u6848\uff1a
\n\u5b89\u5168\u6027\u5982\u4f55\uff0c\u80fd\u4fdd\u8bc1\u4e0d\u540c\u7684\u7528\u6237\u4e4b\u95f4\u65e0\u6cd5\u770b\u5230\u5f7c\u6b64\u7684\u6570\u636e\uff0c\u6216\u8005\u5f71\u54cd\u5f7c\u6b64\u7684\u6570\u636e
\n\u591a\u79df\u6237\u4e4b\u524d\u56e0\u4e3a\u662f\u5171\u4eab\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u8d44\u6e90\u4e89\u62a2\u7684\u95ee\u9898\u80fd\u89e3\u51b3\u4e48\uff1f
\n\u8fd9\u4e2a\u65b9\u6848\u8fd0\u7ef4\u4e0a\u6709\u6ca1\u6709\u4ec0\u4e48\u96be\u70b9
\n\u5f00\u653e\u7684 user \u4f1a\u4e0d\u4f1a\u5bf9\u5b9e\u4f8b\u672c\u8eab\u6709\u5176\u4ed6\u5f71\u54cd
\n\u5c0f\u5f1f\u8fd9\u5757\u7ecf\u9a8c\u786e\u5b9e\u8f83\u5c11\uff0c\u800c chatgpt \u6211\u603b\u611f\u89c9\u4ed6\u6709\u4e9b\u65b9\u6848\u4e0d\u662f\u5f88\u53ef\u4fe1\uff0c\u7279\u6765\u95ee\u95ee\uff0c\u4ee5\u53ca\u6709\u54ea\u5bb6\u7528\u8fd9\u4e2a\u573a\u666f\u5728\u7ebf\u4e0a\u8dd1\u7684\u5417\uff1f
\n", "date_published": "2025-04-11T16:37:19+00:00", "title": "PostgreSQL \u901a\u8fc7\u5206 Database \u505a\u591a\u79df\u6237\u53ef\u884c\u5417\uff1f PostgreSQL \u591a\u79df\u6237\u7684\u6b63\u786e\u59ff\u52bf", "id": "t/1124891" }, { "author": { "url": "member/annoygaga", "name": "annoygaga", "avatar": "https://cdn.v2ex.com/avatar/4a2c/bdb6/227146_large.png?m=1721825554" }, "url": "t/1124522", "date_modified": "2025-04-11T23:58:54+00:00", "content_html": "\u4e4b\u524d\u8fd9\u4e2a\u8ba8\u8bba\u8c8c\u4f3c\u5f88\u591a\u4eba\u8ba8\u8bba\uff0c\u73b0\u5728\u5e0c\u671b\u95ee\u95ee\uff0c\u539f\u56e0\u662f\u76ee\u524d\u6709\u4e00\u4e9b SaaS \u591a\u8868\u7684\u9700\u6c42\uff0c\u5e0c\u671b\u8868\u548c\u5e93\u80fd\u76f8\u5bf9\u66f4\u52a8\u6001\u7684\u542f\u52a8
\n\u76ee\u524d\u5927\u5bb6\u628a\u6570\u636e\u5e93\u653e\u5728 k8s \u90fd\u7528\u4ec0\u4e48\u65b9\u6848\u5462\uff1f\u67e5\u5230\u4e86\u4e00\u4e2a
\nhttps://github.com/cloudnative-pg/cloudnative-pg
\n\u4e0d\u77e5\u9053\u9760\u4e0d\u9760\u8c31
\n\u8fd9\u4e2a\u5e16\u5b50\u5c31\u4e0d\u8ba8\u8bba\u4e3a\u4ec0\u4e48 postgresql \u8981\u653e\u5728 k8s \u4e86\uff0c\u611f\u89c9\u8fd9\u4e2a\u8bdd\u9898\u592a\u5f15\u6218\u4e86\uff0c\u5c31\u5047\u8bbe\u8981\u653e\uff0c\u4e14
\n\u5e0c\u671b\uff1a
\n\u6bcf\u65e5\u5907\u4efd\uff0c\n\u5168\u91cf\u5907\u4efd\uff0c\n\u6570\u636e\u5e76\u53d1\u9ad8\uff0c\u4e0d\u80fd\u505c\u673a\uff0c\n\u6570\u636e\u91cf\u5927\u6982\u5728 200G \uff0c\n\u9700\u8981\u9650\u5236\u5907\u4efd\u65f6\u7684 IO \uff0c\u4e0d\u80fd\u5f71\u54cd\u6b63\u5e38\u7684\u6570\u636e\u8bfb\u5199\uff0c\u76ee\u524d\u662f ssd \u4e86\n\u9700\u8981\u52a0\u5bc6\uff0c\n\u9700\u8981\u538b\u7f29\uff0c\n\u540c\u65f6\u6062\u590d\u65f6\u5e94\u7b80\u5355\u5feb\u901f\uff0c\u5907\u4efd\u6587\u4ef6\u5c3d\u91cf\u5360\u7528\u5c0f\u7684\u7a7a\u95f4
\n\u76ee\u524d\u91c7\u7528\u7684\u662f pg_dump \u7684\u65b9\u6848\uff0c\u5927\u8868\u5206\u6279\u6b21\u5907\u4efd
\n", "date_published": "2025-04-09T02:25:10+00:00", "title": "2025 \u5e74 postgresql \u6709\u4ec0\u4e48\u4f18\u79c0\u7684\u5907\u4efd\u89e3\u51b3\u65b9\u6848", "id": "t/1124151" }, { "author": { "url": "member/zhengfan2016", "name": "zhengfan2016", "avatar": "https://cdn.v2ex.com/gravatar/df526f138d10cac8c95b274c720a6f55?s=73&d=retro" }, "url": "t/1123656", "title": "\u6709\u5927\u795e\u7814\u7a76\u8fc7 pg_resetwal \u7684\u539f\u7406\u5417\uff0c\u4e3a\u4ec0\u4e48\u4f1a\u4e22 user \u8868\u7684\u6570\u636e", "id": "t/1123656", "date_published": "2025-04-07T02:33:16+00:00", "content_html": "\u524d\u60c5\u63d0\u8981\uff1a https://v2ex.com/t/1123446
\n\u76ee\u524d\u7684\u60c5\u51b5\u662f\uff0c\u5927\u90e8\u5206\u6570\u636e\u6062\u590d\u4e86\uff0c\u4f46\u662f\u4e00\u4e9b\u884c\u5f7b\u5e95\u6d88\u5931\u4e86\uff0c\u6211\u89c2\u5bdf\u8fc7\uff0c\u5927\u90e8\u5206\u662f user \u8868\u7684\u7528\u6237\u884c\uff0c\u8fd9\u5230\u5e95\u662f\u4e3a\u4ec0\u4e48\uff0c\u8fd9\u4e9b\u884c\u5b58\u7684\u662f\u6211\u7684\u8d26\u53f7\u6570\u636e\uff0c\u5927\u90e8\u5206\u5728\u5f88\u65e9\u4e4b\u524d\u63d2\u5165\u7684(\u7528\u6237\u6ce8\u518c\u65f6\u5c31\u63d2\u5165\u8be5\u884c\u4e86)\uff0c\u6ca1\u9053\u7406\u5b58\u5728 wal \u7f13\u5b58\u672a\u5199\u5165\uff0c
\n\u4e3b\u8981\u53d7\u5f71\u54cd\u7684\u6709misskey\uff0clogto\u8fd9\u4e9b\u7684 user \u8868
\n\u6211\u5c1d\u8bd5\u521b\u5efa\u548c\u65e7\u8d26\u53f7\u76f8\u540c\u4e3b\u952e\u7684\u7528\u6237\u7684\u65f6\u5019\u4f1a\u51fa\u73b0 id \u4ee5\u5b58\u5728\u7684\u62a5\u9519\uff0c\u5373\u4f7f\u6570\u636e\u5e93\u6839\u672c\u4e0d\u5b58\u5728\u65e7 id \u7684\u884c\uff0creindex \u4e5f\u4e0d\u884c
\n" }, { "author": { "url": "member/zhengfan2016", "name": "zhengfan2016", "avatar": "https://cdn.v2ex.com/gravatar/df526f138d10cac8c95b274c720a6f55?s=73&d=retro" }, "url": "t/1123446", "date_modified": "2025-04-06T04:08:25+00:00", "content_html": "\u5982\u9898\uff0c\u56e0\u4e3a\u670d\u52a1\u5668\u6b7b\u673a\u65ad\u7535\u91cd\u542f\uff0cpostgresql \u62a5\u9519\u4e86\uff0cpostgresql error PANIC: could not locate a valid checkpoint record \uff0c\u6309\u7167\u8fd9\u4e2a\u6559\u7a0b\uff1a
\n\npg_resetwal /var/lib/postgresql/data\n\n\u7ed3\u679c\uff0cpostgresql \u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u662f\u6570\u636e\u5e93\u7a7a\u4e86\uff0c\u53ea\u5269\u4e0b postgres \u5e93\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u5168\u90e8\u4e22\u5931\u4e86\uff0c\u8fd9\u662f\u56e0\u4e3a\u6267\u884c\u5b8c\u8fd9\u4e2a\u547d\u4ee4\u5bfc\u81f4\u7684\u5417
\n", "date_published": "2025-04-05T13:45:13+00:00", "title": "\u6309\u7167 stackoverflow \u6559\u7a0b\u6267\u884c pg_resetwal\uff0c postgresql \u7684\u6570\u636e\u5e93\u88ab\u6e05\u7a7a\u4e86", "id": "t/1123446" }, { "author": { "url": "member/wencan", "name": "wencan", "avatar": "https://cdn.v2ex.com/avatar/0690/9014/5813_large.png?m=1747997681" }, "url": "t/1121195", "title": "\u6c42\u56fd\u5185\u9ad8\u6027\u4ef7\u6bd4\u7684 postgresql \u670d\u52a1\uff0c\u7eb3\u7c73\u9879\u76ee", "id": "t/1121195", "date_published": "2025-03-26T05:41:37+00:00", "content_html": "\u53bb\u5e74\u6211\u597d\u50cf\u95ee\u8fc7\u8fd9\u4e2a\u95ee\u9898\u6211\u5728\u81ea\u5df1\u7684\u963f\u91cc\u4e91\u670d\u52a1\u5668\u4e0a\uff08 2C2G \uff0c3M \uff0cDebian 12 \uff09\u88c5\u4e86\u4e00\u4e2a PostgreSQL \uff08 15 \uff09\uff0c\u5b89\u88c5\u540e\uff0c\u4ec5\u4ec5\u505a\u4e86\u4ee5\u4e0b\u914d\u7f6e\u6539\u52a8\uff1a
\npg_hba.conf:
\n\u6dfb\u52a0\uff1ahost all all 0.0.0.0/0 md5
\npostgresql.conf
\n\u5f00\u653e\u7aef\u53e3\uff1alisten_addresses = '*'
\n\u7ed9 postgres \u8bbe\u7f6e\u4e86\u5bc6\u7801\uff0csudo -i -u postgres -> psql -> \\password
\n\u65e0\u8bba\u662f Navicat \u8fd8\u662f Python \u7684 Psycopg2 \u5728\u8d85\u8fc7\u4e00\u5b9a\u65f6\u95f4\uff08\u5927\u6982 3-5 \u5206\u949f\uff09\uff0c\u5c31\u4f1a\u8fde\u63a5\u5931\u6548\u4e86\u3002
\nNavicat \u62a5\u9519\u5982\u4e0b\uff1a
\nServer closed the connection unexpectedly\nThis probably means the server terminated abnormally before or while processing the request.\n\nPsycopg2 \u62a5\u9519\u5982\u4e0b\uff1a
\npsycopg2.OperationalError: server closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request.\nserver closed the connection unexpectedly\n\tThis probably means the server terminated abnormally\n\tbefore or while processing the request. \n\n\u670d\u52a1\u5668\u6ca1\u6709\u592a\u5927\u7684\u8d1f\u8f7d\uff0ccpu \uff0c\u5185\u5b58\uff0c\u78c1\u76d8\uff0c\u7f51\u7edc\uff0c\u5360\u7528\u7387\u90fd\u5f88\u4f4e\uff0c\u9664\u4e86 Prometheus/Grafana/nginx \u4e4b\u5916\uff0c\u8fd9\u4e2a\u673a\u5668\u4e0a\u53ea\u6709\u521a\u521a\u5b89\u88c5\u7684 PostgreSQL \u3002
\n\u91cd\u65b0\u83b7\u53d6\u8fde\u63a5\uff0c\u80fd\u591f\u6b63\u5e38\u8bbf\u95ee\uff0c\u4f46\u662f\u6211\u4f7f\u7528\u7684 Psycopg2 \u7684 ThreadedConnectionPool \u8fde\u63a5\u6c60\uff0c\u8fde\u63a5\u6c60\u6ca1\u6cd5\u4fdd\u6301\u8fde\u63a5\u4e48\uff1f\u4ee3\u7801\u5982\u4e0b\uff1a
\n\ndef get_pg_pool(pg_config):\n pool = psycopg2.pool.ThreadedConnectionPool(\n mincOnn=1,\n maxcOnn=200,\n host=pg_config['PG_HOST'],\n port=pg_config['PG_PORT'],\n dbname=pg_config['PG_DB'],\n user=pg_config['PG_USER'],\n password=pg_config['PG_PASSWORD'],\n connect_timeout=5,\n )\n return pool\n \n@flask_app.route('/task/log', methods=['GET'])\n def task_log():\n task_log_list = []\n # \u5728\u8fdb\u7a0b\u542f\u52a8\u65f6\uff0c\u7ed9 flask_app \u521d\u59cb\u5316\u4e86\u4e00\u4e2a pg_pool \u5bf9\u8c61\n cOnn= flask_app.pg_pool.getconn()\n try:\n with conn.cursor() as cur:\n cur.execute('SELECT * FROM t_log')\n task_log_list = cur.fetchall()\n except psycopg2.Error as e:\n return JsonResult.failed('\u83b7\u53d6\u65e5\u5fd7\u5217\u8868\u5931\u8d25')\n finally:\n flask_app.pg_pool.putconn(conn)\n\n return JsonResult.successful(task_log_list)\n\n\n\u8fd9\u4e2a\u95ee\u9898\u662f\u548c Linux \u670d\u52a1\u5668\u914d\u7f6e\u6709\u5173\u5462\uff1f\u8fd8\u662f\u8ddf PostgreSQL \u914d\u7f6e\u6709\u5173\uff1f\u8bf7\u95ee\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\u5462\uff1f
\n", "date_published": "2025-03-11T03:10:55+00:00", "title": "\u8bf7\u6559\u4e00\u4e2a\u5173\u4e8e PostgreSQL \u8fde\u63a5\u88ab Server \u5173\u95ed\u7684\u95ee\u9898", "id": "t/1117481" }, { "author": { "url": "member/jinyan01", "name": "jinyan01", "avatar": "https://cdn.v2ex.com/avatar/fff4/5b07/435749_large.png?m=1773651154" }, "url": "t/1113761", "date_modified": "2025-02-24T03:09:38+00:00", "content_html": "", "date_published": "2025-02-24T03:08:43+00:00", "title": "PostgreSQL 18 JSONB \u589e\u52a0\u80fd\u53d6\u4ee3 MongoDB \u5417\uff1f", "id": "t/1113761" }, { "author": { "url": "member/zjc97816", "name": "zjc97816", "avatar": "https://cdn.v2ex.com/gravatar/4db795abf5e5f644522332596389c88b?s=73&d=retro" }, "url": "t/1099147", "title": "PostgreSql", "id": "t/1099147", "date_published": "2024-12-20T09:54:48+00:00", "content_html": "PostgreSql \u4ea4\u6d41
\n" }, { "author": { "url": "member/qviqvi", "name": "qviqvi", "avatar": "https://cdn.v2ex.com/gravatar/402cd361d8b2821d08ec9e1d892940f8?s=73&d=retro" }, "url": "t/1098343", "title": "Oracle \u8fc1\u79fb postgreSQL \uff0c\u6709\u4ec0\u4e48\u7ecf\u9a8c\u5206\u4eab", "id": "t/1098343", "date_published": "2024-12-17T17:30:33+00:00", "content_html": "\u9a6c\u4e0a\u8981\u8fc1\u79fb\u6570\u636e\u4e86\uff0c\u4e0d\u8fc7\u4ee3\u7801\u548c\u539f oracle \u6570\u636e\u5e93\u90fd\u662f\u7956\u4f20\u7684\uff0c\u7f3a\u4e4f\u6587\u6863\uff0c\u4e0d\u77e5\u9053\u600e\u4e48\u8fc1\u79fb\u6bd4\u8f83\u597d\uff0c\u6c42\u7ecf\u9a8c\u5206\u4eab
\n" }, { "author": { "url": "member/dzdh", "name": "dzdh", "avatar": "https://cdn.v2ex.com/avatar/1683/7ebf/226307_large.png?m=1757987240" }, "url": "t/1086318", "title": "\u6709\u4ec0\u4e48\u6743\u9650\u7ba1\u7406\u6700\u4f73\u5b9e\u8df5\u5417", "id": "t/1086318", "date_published": "2024-11-04T01:51:05+00:00", "content_html": "\u573a\u666f\u662f\u8fd9\u6837\u3002
\n\u4e00\u4e2a\u5e93 owner \u662f user
\n\u51e0\u4e2a\u5f00\u53d1\u8005 \u53ea\u6709\u53ea\u8bfb\u548c\u5efa\u8868\u5220\u8868\u6743\u9650 usera/userb
\n\u5f00\u53d1\u8005\u81ea\u5df1\u5efa\u7684\u8868\u4f1a\u81ea\u52a8 owner \u7ed9\u81ea\u5df1\u3002\u5bfc\u81f4\u5176\u4ed6\u4eba\u6ca1\u6743\u9650\u3002
\n\u963f\u91cc\u4e91 rds-pg \u3002\u6709\u4ec0\u4e48\u89e3\u51b3\u65b9\u6848\uff1f
\n" }, { "author": { "url": "member/guzzhao", "name": "guzzhao", "avatar": "https://cdn.v2ex.com/avatar/dde6/1522/248437_large.png?m=1717910920" }, "url": "t/1080792", "title": "\u8bf7\u6559 PostgreSQL \u548c PostGIS \u4f7f\u7528\u95ee\u9898", "id": "t/1080792", "date_published": "2024-10-16T06:15:03+00:00", "content_html": "\u4e3b\u952e\u95ee\u9898, \u4f7f\u7528 serial \u521b\u5efa\u81ea\u589e\u4e3b\u952e\u540e,ddl \u4f1a\u53d8\u6210 int4+nextval,\u6211\u77e5\u9053\u610f\u601d\u4e00\u6837\u4f46\u662f\u8fd9\u6837\u590d\u5236\u7684 ddl \u4e0d\u80fd\u76f4\u63a5\u7528,\u80fd\u4e0d\u80fd\u6709\u597d\u7684\u5904\u7406\u65b9\u6cd5. \u4f7f\u7528 uuid?
\n\u521b\u5efa\u7684 geography \u7c7b\u578b\u7528 Java \u5b9e\u4f53\u600e\u4e48\u5b9a\u4e49,\u67e5\u8be2\u7684\u65f6\u5019\u4f7f\u7528 postgis \u7684 PGgeography,\u4f46\u662f\u65b0\u589e\u8ba9\u524d\u7aef\u4f20\u4ec0\u4e48\u683c\u5f0f\u600e\u4e48\u5904\u7406
select to_timestamp('1672531200000'::bigint / 1000) AT TIME ZONE 'UTC-8';\n\n\u7ed3\u679c\u4e3a 2023-01-01 08:00:00
\nselect to_timestamp('1672531200000'::bigint / 1000) AT TIME ZONE 'UTC+8';\n\n\u7ed3\u679c\u4e3a 2022-12-31 16:00:00
\n\u4e3a\u4ec0\u4e48'UTC-8'\u624d\u662f\u5317\u4eac\u65f6\u95f4?
\n" }, { "author": { "url": "member/Koril", "name": "Koril", "avatar": "https://cdn.v2ex.com/avatar/82b2/a98c/625662_large.png?m=1760412808" }, "url": "t/1072744", "date_modified": "2024-09-13T23:13:37+00:00", "content_html": "\u5404\u4f4d\u5927\u4f6c\uff0c\u6709\u4e2a\u95ee\u9898\u8bf7\u6559\u4e0b\n\u6211\u5728\u672c\u5730\uff08 Windows11 \uff09\u5b89\u88c5\u4e86\u4e00\u4e2a PostgreSQL \uff0c\u4e00\u5207\u90fd\u662f\u9ed8\u8ba4\u503c\u5b89\u88c5
\n\u6211\u901a\u8fc7\u4ee5\u4e0b\u8bed\u53e5\u67e5\u5230 max connections \u7684\u503c\u662f 100
\nshow max_connections; -- \u8fd4\u56de 100\n\n\u6211\u731c\u6d4b\u8fd9\u4e2a\u5e94\u8be5\u5c31\u662f PG \u9ed8\u8ba4\u7684\u6700\u5927\u8fde\u63a5\u6570\uff0c\u7136\u540e\u6211\u7528 Python \u5199\u4e86\u4e00\u4e2a\u811a\u672c\uff0c\u5faa\u73af\u83b7\u53d6 connection\uff1a
\nimport psycopg2\nimport time\n\ndef get_db_conn():\n cOnn= psycopg2.connect(host='localhost',port=5432,database='study_demo',user='postgres',password='123456')\n return conn\n\ndef main():\n conn_list = list()\n for i in range(100):\n print(f'\u83b7\u53d6\u7b2c {i} \u4e2a\u8fde\u63a5')\n try:\n conn_list.append(get_db_conn())\n except Exception:\n print(f'\u83b7\u53d6\u7b2c {i} \u4e2a\u8fde\u63a5\u5931\u8d25')\n print(f'\u6210\u529f\u83b7\u53d6 {len(conn_list)} \u4e2a\u8fde\u63a5')\n time.sleep(60)\n \nif __name__ == '__main__':\n main()\n\n\u7136\u540e\u4ee3\u7801\u663e\u793a\u83b7\u53d6\u5230\u4e86 95 \u4e2a\u8fde\u63a5\uff0c\u7136\u540e\u6211\u901a\u8fc7\u4ee5\u4e0b SQL \u83b7\u53d6\u8fde\u63a5\u6570
\nselect count(*) from pg_stat_activity; -- \u8fd4\u56de 105\n\n\u6211\u9884\u6d4b\u7684\u503c\u5e94\u8be5\u662f\uff1a
\n\u4f46\u662f\u7ed3\u679c\u5b8c\u5168\u4e0d\u4e00\u6837\uff0c105 \u660e\u663e\u8d85\u8fc7\u4e86\uff0c\u8fd9\u591a\u51fa\u6765\u7684 5 \u4e2a\u662f\u5982\u4f55\u5f97\u5230\u7684\uff1f
\n", "date_published": "2024-09-13T10:04:05+00:00", "title": "\u5173\u4e8e PostgreSQL \u4e2d\u7684 max_connections \u548c pg_stat_activity \u7684\u7591\u60d1", "id": "t/1072744" }, { "author": { "url": "member/wencan", "name": "wencan", "avatar": "https://cdn.v2ex.com/avatar/0690/9014/5813_large.png?m=1747997681" }, "url": "t/1072470", "date_modified": "2024-09-12T22:40:05+00:00", "content_html": "\u4e00\u4e2a\u5c0f\u670d\u52a1\u770b\u7f51\u4e0a\u7684 blog \uff0c\u597d\u9ebb\u70e6\u554a\uff0cpostgres \u5c31\u4e0d\u80fd\u51fa\u4e2a\u7248\u672c\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u51cf\u5c11\u6216\u6d88\u9664\u4eba\u5de5\u914d\u7f6e\u5e72\u9884\uff1f
\n", "date_published": "2024-08-24T03:17:34+00:00", "title": "\u65b0\u624b\uff0c\u8bf7\u95ee postgres \u600e\u4e48\u914d\u7f6e vacuum", "id": "t/1067432" }, { "author": { "url": "member/qviqvi", "name": "qviqvi", "avatar": "https://cdn.v2ex.com/gravatar/402cd361d8b2821d08ec9e1d892940f8?s=73&d=retro" }, "url": "t/1062183", "title": "\u5b66\u4e60 PostgreSQL\uff0c\u6709\u4ec0\u4e48\u8d44\u6599\u63a8\u8350\uff1f", "id": "t/1062183", "date_published": "2024-08-03T01:42:15+00:00", "content_html": "\u6709 Oracle \u548c MySQL \u7ecf\u9a8c\uff0c\u4ee5\u540e\u53ef\u80fd\u8f6c Postgre \uff0c\u4f46 PostgreSQL \u8d44\u6599\u597d\u5c11\uff0c\u6c42\u63a8\u8350
\n" }, { "author": { "url": "member/dwu8555", "name": "dwu8555", "avatar": "https://cdn.v2ex.com/avatar/80ef/3e1b/293789_large.png?m=1734394843" }, "url": "t/1055573", "title": "Apache AGE \u548c Neo4j \u54ea\u4e2a\u66f4\u597d\uff1f", "id": "t/1055573", "date_published": "2024-07-08T02:52:14+00:00", "content_html": "\u6211\u633a\u559c\u6b22 PostgreSQL \u7684\uff0c\u4e0d\u60f3\u5207\u6362\u5176\u4ed6\u7684\u6570\u636e\u5e93
\n" }, { "author": { "url": "member/dwu8555", "name": "dwu8555", "avatar": "https://cdn.v2ex.com/avatar/80ef/3e1b/293789_large.png?m=1734394843" }, "url": "t/1055527", "title": "\u6709\u6ca1\u6709\u50cf Citus \u90a3\u6837\u65b9\u4fbf\u5206\u7247\u7684\u56fe\u6570\u636e\u5e93?", "id": "t/1055527", "date_published": "2024-07-08T00:56:02+00:00", "content_html": "" }, { "author": { "url": "member/itx10237", "name": "itx10237", "avatar": "https://cdn.v2ex.com/avatar/b106/0131/623098_large.png?m=1720230147" }, "url": "t/1055254", "title": "\u600e\u6837\u4f7f\u7528 C \u8bed\u8a00\u8bbf\u95ee PostgreSQL \u96c6\u7fa4\uff1f", "id": "t/1055254", "date_published": "2024-07-06T01:35:32+00:00", "content_html": "\u5b98\u7f51 https://www.postgresql.org/docs/14/libpq-connect.html \u7684\u6587\u6863\u4f3c\u4e4e\u6ca1\u6709\u63d0\u4f9b\u8bbf\u95ee PostgreSQL \u96c6\u7fa4\u7684 api \u3002\u5927\u5bb6\u80fd\u5e2e\u5fd9\u63d0\u4f9b\u4e00\u4e0b\u8d44\u6599\u5417\uff1f
\n" }, { "author": { "url": "member/gosky", "name": "gosky", "avatar": "https://cdn.v2ex.com/gravatar/786267342d5e7b4c7bd7891c52200d49?s=73&d=retro" }, "url": "t/1051235", "date_modified": "2024-06-20T09:25:49+00:00", "content_html": "\u4e00\u53f0\u4f4e\u914d\u670d\u52a1\u5668\u4e4b\u524d\u4e00\u76f4\u7528 MySQL \uff0c\u6700\u8fd1\u4e00\u4e2a\u65b0\u9879\u76ee\u7528\u7684\u662f PostgreSQL \u3002
\nPostgreSQL \u6ca1\u6709 on update current_timestamp \u53ea\u80fd\u901a\u8fc7\u89e6\u53d1\u5668\u6765\u5b9e\u73b0\u3002
\u8fd9\u6837\u7684\u8bdd\u6bcf\u4e2a\u8868\u90fd\u8981\u521b\u5efa\u4e00\u4e2a trigger \uff0c\u611f\u89c9\u597d\u9ebb\u70e6\u3002
\n" }, { "author": { "url": "member/yustation", "name": "yustation", "avatar": "https://cdn.v2ex.com/gravatar/a6b26496372965d940c4ad745748b767?s=73&d=retro" }, "url": "t/1046815", "title": "\u4e3b\u4ece\u540c\u6b65\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u53ef\u4ee5\u548c\u6570\u636e\u5e93\u7aef\u53e3\u53f7\u4e0d\u540c\u5417\uff1f", "id": "t/1046815", "date_published": "2024-06-04T12:58:20+00:00", "content_html": "\u8bf7\u6559\u5404\u4f4d\uff0c\u4e24\u53f0\u4e3b\u673a\u4e0a\u7684 pgsql \uff0c\u914d\u7f6e\u4e86\u4e3b\u4ece\u540c\u6b65\uff0c\u600e\u6837\u914d\u7f6e\u624d\u80fd\u8ba9\u4e24\u4e2a\u6570\u636e\u5e93\u4e92\u901a\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u4e0e\u6570\u636e\u5e93\u672c\u8eab\u8fde\u63a5\u4f7f\u7528\u7684\u7aef\u53e3\u53f7\u4e0d\u540c\u5462\uff1f
\n" }, { "author": { "url": "member/teli", "name": "teli", "avatar": "https://cdn.v2ex.com/gravatar/e2d0410ad1743108f0131e1ccb3ac0c6?s=73&d=retro" }, "url": "t/1044093", "date_modified": "2024-05-26T11:19:32+00:00", "content_html": "\u5ba2\u6237\u7aef\u662f DBeaver \u3002
\nPostgreSQL \u662f\u963f\u91cc\u4e91\u4e91\u670d\u52a1\u5668\u7684 docker \u8dd1\u7684\u4e0a\u3002
\n\u5361\u7684\u64cd\u4f5c\u6709\uff1a\u521b\u5efa\u8868\u3001\u7b80\u5355\u7684\u67e5\u8be2
\n\u5361\u7684\u8868\u73b0\u4e3a\uff1a\u4e00\u76f4\u5361\u5728\u90a3\uff0c\u4e00\u76f4\u65e0\u8fd4\u56de\uff0c\u53d6\u6d88\u90fd\u5361 \u3002\u8981\u4e48\u5e72\u561b\u90fd\u5361\uff0c\u8981\u4e48\u90fd\u4e0d\u5361
\u53e6\u5916\u8fd8\u6709\u53e6\u4e00\u4e2a\u811a\u672c\u5728\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u64cd\u4f5c\u6709\u4e0b\u9762\u4e24\u4e2a\uff1a
\nSELECT COUNT(*) FROM public.XXX WHERE qa_code = %s\n\nINSERT INTO public.XXX\n(qa_code, department, title, description, answer)\nVALUES(%s, %s, %s, %s, %s)\n\n\u4e4b\u524d\u73a9 CockroachDB \uff0c\u4e5f\u9047\u5230\u8fc7\u4e00\u6837\u7684\u60c5\u51b5
\n", "date_published": "2024-05-26T11:19:06+00:00", "title": "\u4e3a\u4ec0\u4e48\u6709\u65f6 PostgreSQL \u6709\u65f6\u4f1a\u8868\u73b0\u5f97\u6bd4\u8f83\u5361\uff1f", "id": "t/1044093" }, { "author": { "url": "member/teli", "name": "teli", "avatar": "https://cdn.v2ex.com/gravatar/e2d0410ad1743108f0131e1ccb3ac0c6?s=73&d=retro" }, "url": "t/1043881", "title": "\u7b2c\u4e00\u6b21\u4f7f\u7528 PostgreSQL\uff0c\u8fde\u5efa\u8868\u90fd\u4e0d\u4f1a\uff0c\u8bf7\u6559\u70b9\u7ecf\u9a8c", "id": "t/1043881", "date_published": "2024-05-25T07:46:09+00:00", "content_html": "\u8003\u8651 ai \u65f6\u4ee3\u4e86\u3002\u4e3a\u4e86\u7528\u4e0a pgvector \uff0c\u5c1d\u8bd5\u63a5\u4e0b\u6765\u628a\u4e3b\u6570\u636e\u5e93\u76f4\u63a5\u6362\u7528 pg \u3002
\n\u8bf7\u6559\u70b9\u7ecf\u9a8c
\n\u4e4b\u524d mysql \u65f6\uff0cupdate_time \u662f\u81ea\u52a8\u66f4\u65b0\u3002postgres \u597d\u50cf\u4e0d\u80fd\u81ea\u52a8\u66f4\u65b0\uff0c\u6709\u4ec0\u4e48\u597d\u7684\u66ff\u4ee3\u65b9\u6848\u3002
\n" }, { "author": { "url": "member/wanniwa", "name": "wanniwa", "avatar": "https://cdn.v2ex.com/avatar/b5bd/0c79/362568_large.png?m=1691310579" }, "url": "t/1041239", "date_modified": "2024-05-16T02:52:53+00:00", "content_html": "\u6bd4\u5982\u8fd9\u79cd\u67e5\u8be2\u6709\u6ca1\u6709\u5c01\u88c5\u597d\u7684 select * from xxx where tags @> ARRAY[tag1,tag2,tag3]", "date_published": "2024-05-16T02:52:35+00:00", "title": "Java \u6709\u6ca1\u6709\u9488\u5bf9 PostgreSQL \u597d\u7528\u4e00\u70b9\u7684 ORM", "id": "t/1041239" }, { "author": { "url": "member/JackyTsang", "name": "JackyTsang", "avatar": "https://cdn.v2ex.com/gravatar/fb4f5f6a3eb2dd16dbbb3df26cc21a8b?s=73&d=retro" }, "url": "t/1041038", "date_modified": "2024-05-15T10:02:48+00:00", "content_html": "\u53ef\u80fd\u6211\u7406\u89e3\u5f97\u6bd4\u8f83\u7b80\u5355\uff0c\u5c31\u662f\u5047\u8bbe\u4e00\u4e2a\u751f\u4ea7\u7684 PostgreSQL \u6570\u636e\u5e93\u7684 A \u3001B \u3001C \u5e93\uff0c\u90fd\u5b9e\u65f6\u6216 Cron \u5b9a\u65f6\u5730\u540c\u6b65\u5230\u53e6\u5916\u4e00\u4e2a PostgreSQL \u6570\u636e\u5e93\u7684 A \u3001B \u3001C \u5e93\u3002PostgreSQL \u542f\u52a8\u5931\u8d25\uff0c\u62a5\u9519\u548c\u4e0b\u9762\u7c7b\u4f3c
\n2022-05-29 21:52:22.926 CST [35270] LOG: starting PostgreSQL 14.3 on x86_64-pc-linux-gnu,\ncompiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit\n2022-05-29 21:52:22.927 CST [35270] LOG: listening on IPv6 address \"::1\", port 5432\n2022-05-29 21:52:22.927 CST [35270] LOG: listening on IPv4 address \"127.0.0.1\", port 5432\n2022-05-29 21:52:22.929 CST [35270] LOG: listening on Unix socket \"/var/run/postgresql/.s.PGSQL.5432\"\n2022-05-29 21:52:22.931 CST [35270] LOG: listening on Unix socket \"/tmp/.s.PGSQL.5432\"\n2022-05-29 21:52:22.936 CST [35272] LOG: database system was interrupted; last known up at 2022-05-28 21:36:11 CST\n2022-05-29 21:52:23.049 CST [35272] LOG: invalid primary checkpoint record\n2022-05-29 21:52:23.049 CST [35272] PANIC: could not locate a valid checkpoint record\n2022-05-29 21:52:24.211 CST [35270] LOG: startup process (PID 35272) was terminated by signal 6: Aborted\n2022-05-29 21:52:24.211 CST [35270] LOG: aborting startup due to startup process failure\n2022-05-29 21:52:24.218 CST [35270] LOG: database system is shut down
\n\u6839\u636e\u7f51\u4e0a\u67e5\u8be2\u7684\u5230\u4fe1\u606f\uff0c\u201c\u91cd\u8bbe wal\u201d\u5373\u53ef\u89e3\u51b3\u201d\uff0c\u4f46\u8fd9\u6837\u64cd\u4f5c\u53ef\u80fd\u4f1a\u4e22\u5931\u6570\u636e\uff0c\u60f3\u77e5\u9053\u5982\u4f55\u5224\u65ad\u5927\u6982\u4f1a\u4e22\u5931\u54ea\u4e9b\u6570\u636e\uff0c\u56e0\u4e3a\u662f\u751f\u4ea7\u73af\u5883\uff0c\u9700\u8981\u8bc4\u4f30\u4e00\u4e0b\uff0c\u57a6\u6c42\u5404\u4f4d\u53d1\u8868\u81ea\u5df1\u7684\u770b\u6cd5 \uff0c\u4e0d\u80dc\u611f\u6fc0\u3002
\n", "date_published": "2024-05-09T13:09:11+00:00", "title": "PostgreSQL \u542f\u52a8\u5931\u8d25", "id": "t/1039248" }, { "author": { "url": "member/wzw", "name": "wzw", "avatar": "https://cdn.v2ex.com/avatar/c72a/cf0f/78954_large.png?m=1699319258" }, "url": "t/1036625", "date_modified": "2024-04-29T10:53:50+00:00", "content_html": "\u76ee\u524d\u9700\u8981\u4e0a\u65b0\u9879\u76ee, \u7528\u4e86 PostgreSQL, \u8fd9\u6837\u7684\u8bbe\u7f6e\u662f\u4e0d\u662f\u6b63\u5e38\u60c5\u51b5\u4e0b, \u6700\u7b80\u5355\u6700\u5408\u9002?
\n\u8c22\u8c22
\npg_createcluster 16 main --locale=C --encoding=UTF8 --start\n\n===
\n\u770b\u5230\u8fd9\u7bc7\u6587\u7ae0
\nPG \u4e2d\u7684\u672c\u5730\u5316\u6392\u5e8f\u89c4\u5219\nhttps://pigsty.io/zh/blog/admin/collate/
\n\u91cc\u9762\u63d0\u5230:
\n\u4e3a\u4ec0\u4e48 Pigsty \u5728\u521d\u59cb\u5316 Postgres \u6570\u636e\u5e93\u65f6\u9ed8\u8ba4\u6307\u5b9a\u4e86 locale=C \u4e0e encoding=UTF8
\n\u7b54\u6848\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u9664\u975e\u771f\u7684\u660e\u786e\u77e5\u9053\u81ea\u5df1\u4f1a\u7528\u5230 LOCALE \u76f8\u5173\u529f\u80fd\uff0c\u5426\u5219\u5c31\u6839\u672c\u4e0d\u5e94\u8be5\u914d\u7f6e C.UTF8 \u4e4b\u5916\u7684\u4efb\u4f55\u5b57\u7b26\u7f16\u7801\u4e0e\u672c\u5730\u5316\u6392\u5e8f\u89c4\u5219\u9009\u9879
\n", "date_published": "2024-04-29T02:02:50+00:00", "title": "PostgreSQL \u6570\u636e\u5e93 \u6b63\u5e38\u60c5\u51b5\u4e0b\u6307\u5b9a\u4e86 locale=C \u4e0e encoding=UTF8 (\u6700\u7b80\u5355)", "id": "t/1036625" }, { "author": { "url": "member/mingwiki", "name": "mingwiki", "avatar": "https://cdn.v2ex.com/avatar/a2f7/0209/282577_large.png?m=1743062267" }, "url": "t/1036295", "title": "\u9519\u8bef\u8fc1\u79fb pgsql \u5bfc\u81f4\u65e5\u5fd7\u62a5 warning\uff0c\u8bf7\u95ee\u5982\u4f55\u89e3\u51b3\uff1f", "id": "t/1036295", "date_published": "2024-04-28T02:28:39+00:00", "content_html": "\u6362\u7cfb\u7edf\u7684\u65f6\u5019\u56fe\u7b80\u5355\u8111\u5b50\u62bd\u62bd\u4e86\uff0c\u76f4\u63a5 tar czf /var/lib/postgresql \u3002\u540e\u89e3\u538b\u653e\u5230\u65b0\u7cfb\u7edf/var/lib \u76ee\u5f55\u4e0b,\u6ca1\u6709\u7528 dump pgloader \u4e4b\u7c7b\u7684\u5de5\u5177\u3002\u73b0\u5728\u6240\u6709\u7684 database \u4e00\u76f4\u62a5\u540c\u4e00\u4e2a\u9519\uff0c\u4e0d\u91cd\u5efa\u6240\u6709\u6570\u636e\u5e93\u53ef\u4ee5\u89e3\u51b3\u5417\uff1f\n\u62a5\u9519\u5982\u4e0b\uff0c\u67e5\u8be2 gemini/gpt3.5 \u65e0\u679c\uff0c\u5c1d\u8bd5ALTER DATABASE xxx REFRESH COLLATION VERSION;\u663e\u793a invalid collation version. \u8bf7\u95ee\u5927\u4f6c\u4eec\u5982\u4f55\u89e3\u51b3\uff1f
\"2024-04-28 10:07:27.248 CST [3392] WARNING: database \\\"template1\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:07:39.298 CST [3393] WARNING: database \\\"postgres\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:07:49.150 CST [3398] WARNING: database \\\"vaultwarden\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:07:49.150 CST [3399] WARNING: database \\\"vaultwarden\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:07:51.323 CST [3400] WARNING: database \\\"vaultwarden\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:08:03.244 CST [3401] WARNING: database \\\"miniflux\\\" has no actual collation version, but a version was recorded\",\n\"2024-04-28 10:08:15.275 CST [3402] WARNING: database \\\"core\\\" has no actual collation version, but a version was recorded\",\n\n" }, { "author": { "url": "member/coinbase", "name": "coinbase", "avatar": "https://cdn.v2ex.com/avatar/6968/2696/667684_large.png?m=1715427512" }, "url": "t/1028253", "title": "\u4ece Mongodb \u5230 PostgreSQL \u7684\u5927\u8fc1\u79fb", "id": "t/1028253", "date_published": "2024-03-29T13:48:10+00:00", "content_html": "https://infisical.com/blog/postgresql-migration-technical
\n" }, { "author": { "url": "member/Comyn", "name": "Comyn", "avatar": "https://cdn.v2ex.com/avatar/91b2/7ea7/374049_large.png?m=1775814584" }, "url": "t/1027812", "title": "\u6709\u65e0 pg \u7684\u5165\u95e8\u7cbe\u8fdb\u535a\u5ba2\u6216\u8005\u89c6\u9891\u63a8\u8350", "id": "t/1027812", "date_published": "2024-03-28T07:46:38+00:00", "content_html": "" }, { "author": { "url": "member/sirthisman", "name": "sirthisman", "avatar": "https://cdn.v2ex.com/avatar/cc63/200f/354803_large.png?m=1559783972" }, "url": "t/1019809", "title": "\u6709\u4ec0\u4e48\u4e0d\u901a\u8fc7\u5199\u811a\u672c\u7684\u65b9\u5f0f\uff0c\u5c06 postgreSQL \u7684\u5efa\u8868\u8bed\u53e5\u8f6c\u6362\u4e3a doris \u7684\u5efa\u8868\u8bed\u53e5\u5417\uff1f", "id": "t/1019809", "date_published": "2024-03-01T07:02:47+00:00", "content_html": "\u6c42\u52a9\uff0c\u6211\u4eec\u8981\u505a\u4ece hawq \u5f15\u64ce\uff08\u5efa\u8868\u8bed\u53e5\u662f postgreSQL \u683c\u5f0f\uff09\u5230 Starrocks \uff08\u5efa\u8868\u8bed\u53e5\u662f doris \u683c\u5f0f\uff09\u6570\u636e\u5e93\u7684\u6570\u636e\u8fc1\u79fb\u3002\u5927\u6982\u6570\u767e\u5f20\u8868\u3002\u9700\u8981\u5728 Starrocks \u4e2d\u540c\u6b65\u5bf9\u5e94\u8868\u7ed3\u6784\u3002\u8bf7\u6559\u4e0b\u5404\u4f4d\u6709\u4ec0\u4e48\u5de5\u5177\u53ef\u4ee5\u6279\u91cf\u8f6c\u6362\u5efa\u8868\u8bed\u53e5\u4e48\uff1f
\n" }, { "author": { "url": "member/coinbase", "name": "coinbase", "avatar": "https://cdn.v2ex.com/avatar/6968/2696/667684_large.png?m=1715427512" }, "url": "t/1016671", "title": "\u65b0\u7684 PostgreSQL \u8bed\u8a00\u63d2\u4ef6 PL/PRQL", "id": "t/1016671", "date_published": "2024-02-19T14:10:05+00:00", "content_html": "https://github.com/kaspermarstal/plprql
\n" }, { "author": { "url": "member/qweruiop", "name": "qweruiop", "avatar": "https://cdn.v2ex.com/avatar/d6c7/d64e/634178_large.png?m=1704960981" }, "url": "t/1014708", "date_modified": "2024-02-07T14:44:32+00:00", "content_html": "\u73b0\u5728\u6709 2 \u5f20\u8868\uff1astudent \u548c transactions
\nstudent \u957f\u8fd9\u6837\uff1a
\n| id | \nname | \n
|---|---|
| 1 | \na | \n
| 2 | \nb | \n
| 3 | \nc | \n
transactions
\n| id | \nstudent_id | \nupdated_at | \n
|---|---|---|
| 1 | \n1 | \n2024-02-06T16:41:05+08:00 | \n
| 2 | \n1 | \n2024-02-06T13:41:05+08:00 | \n
| 3 | \n2 | \n2024-02-06T12:41:05+08:00 | \n
\u73b0\u5728\u60f3\u5728 postgres \u91cc\u9762\u7528\u4e00\u4e2a sql \uff0c\u67e5\u51fa\u6bcf\u4e2a\u7528\u6237\u7684 transaction \u6570\u91cf\uff0c\u5e76\u4e14\u628a\u6ca1\u6709\u7684\u591a\u4e00\u884c\u4e3a 0 \u3002
\nSELECT s.id AS student_id, s.name, COUNT(t.id) AS transactions_count\nFROM student s\nLEFT JOIN transactions t ON s.id = t.student_id\nGROUP BY s.id, s.name;\n\n\u4f46\u662f\u8fd9\u6837\uff0c\u67e5\u51fa\u6765\u7684\u7ed3\u679c\u662f
\n| student_id | \nname | \ntransactions_count | \n
|---|---|---|
| 1 | \na | \n2 | \n
| 2 | \nb | \n1 | \n
\u4f46\u662f\u6211\u4eec\u9700\u8981\u67e5\u51fa\u7684\u7ed3\u679c\u662f
\n| student_id | \nname | \ntransactions_count | \n
|---|---|---|
| 1 | \na | \n2 | \n
| 2 | \nb | \n1 | \n
| 3 | \nc | \n0 | \n
\u6c42\u6559\u5404\u4f4d\u9ad8\u624b\u6307\u70b9\u4e0b\u8fd9\u4e2a sql \u600e\u4e48\u5199\u3002\u3002\u3002
\n", "date_published": "2024-02-06T08:47:45+00:00", "title": "\u8bf7\u6559\u4e00\u4e2a\u7ecf\u5178\u7684 postgres \u7684 sql \u600e\u4e48\u5199", "id": "t/1014708" }, { "author": { "url": "member/ryan19961996", "name": "ryan19961996", "avatar": "https://cdn.v2ex.com/gravatar/48f9393fadf952117aea6976b1e7f077?s=73&d=retro" }, "url": "t/1011215", "title": "\u6d17\u6570\u636e\uff1a\u5982\u4f55\u5c06 Contact \u548c ContactTag \u591a\u5bf9\u591a\u5173\u8054\u8d77\u6765", "id": "t/1011215", "date_published": "2024-01-24T07:42:31+00:00", "content_html": "model Contact {\n id String @id @default(cuid())\n metadata Json? @db.JsonB\n contactTags ContactTag[]\n ...\n @@index([metadata(ops: JsonbPathOps)], type: Gin)\n}\n\nmodel ContactTag {\n id String @id @default(cuid())\n slug String\n contacts Contact[]\n ...\n}\n\n\u7531\u4e8e\u5386\u53f2\u9057\u7559\u539f\u56e0\uff0cContact \u548c ContactTag \u4e4b\u524d\u6ca1\u6709\u5173\u8054\u5173\u7cfb\u3002Contact \u7684 metadata \u91cc\u9762\u5197\u4f59\u4e86\u4e00\u4efd tags,\u7c7b\u4f3c {tags:[\"newsletter\",\"new-customer\"]}\u3002\u901a\u8fc7\u6807\u7b7e\u7b5b\u9009 Contact \u7684\u65f6\u5019\uff0c\u662f\u901a\u8fc7 \u67e5\u627e metadata \u7684 tags \u3002\u4f46\u662f\u6548\u7387\u786e\u5b9e\u592a\u4f4e\u4e86, Contact \u8868\u7684\u6570\u91cf\u5f88\u591a\uff0c\u5927\u6982\u662f 1350 \u4e07\u884c\u3002\u6240\u4ee5\u6211\u4eec\u60f3\u989d\u5916\u52a0\u4e00\u4e2a\u8868\u5b58\u50a8\u5173\u8054\u5173\u7cfb\u3002\u8bf7\u6559\u4e00\u4e0b\u5404\u4f4d\u5927\u4f6c\uff0c\u76f8\u5e94\u7684 sql \u600e\u4e48\u5199\uff1f
\n" }, { "author": { "url": "member/danielxuforever", "name": "danielxuforever", "avatar": "https://cdn.v2ex.com/avatar/d1cb/3494/572974_large.png?m=1726550412" }, "url": "t/1010986", "title": "Postgres \u5728\u4e2d\u56fd\u8fd8\u80fd\u8d77\u6765\u4e48\uff1f", "id": "t/1010986", "date_published": "2024-01-23T11:45:05+00:00", "content_html": "\u4eca\u5929\uff0c\u641c\u7d22\u4e86\u4e00\u4e0b PG \u548c MySQL \u4e3a\u4ec0\u4e48\u5728\u4e2d\u56fd\u5e02\u573a\u5dee\u8fd9\u4e48\u591a\uff08 10 \u88ab\uff09\u7684\u539f\u56e0\uff0c\u4e3b\u8981\u6709\uff1a\u8c8c\u4f3c\u8fd8\u4e0d\u9519
\n" } ] } ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86