{"id":21447,"date":"2024-01-02T09:32:22","date_gmt":"2024-01-02T09:32:22","guid":{"rendered":"https:\/\/server.hk\/blog\/21447\/"},"modified":"2024-11-14T10:34:12","modified_gmt":"2024-11-14T02:34:12","slug":"how-to-fix-postgresql-error-code-54011-too_many_columns","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21447\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns"},"content":{"rendered":"<p>=<\/p>\n<h1 id=\"how-to-fix-postgresql-error-code-54011-too_many_columns-ntuBuPjMSL\">\u5982\u4f55\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns<\/h1>\n<p>PostgreSQL \u662f\u4e00\u500b\u5f37\u5927\u7684\u958b\u6e90\u95dc\u806f\u5f0f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u5834\u5408\u3002\u7136\u800c\uff0c\u50cf\u4efb\u4f55\u8edf\u4ef6\u4e00\u6a23\uff0c\u5b83\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u932f\u8aa4\uff0c\u5f71\u97ff\u5176\u529f\u80fd\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u5c31\u662f PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u8a72\u932f\u8aa4\u7684\u539f\u56e0\u4e26\u63d0\u4f9b\u76f8\u61c9\u7684\u89e3\u6c7a\u65b9\u6848\u4f86\u4fee\u5fa9\u5b83\u3002<\/p>\n<h2 id=\"understanding-postgresql-error-code-54011-too_many_columns-ntuBuPjMSL\">\u7406\u89e3 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns<\/h2>\n<p>\u5728\u4f7f\u7528 PostgreSQL \u6642\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u932f\u8aa4\u8a0a\u606f\u300cERROR: too_many_columns: target lists can have at most 1664 entries\u300d\u3002\u6b64\u932f\u8aa4\u767c\u751f\u5728\u60a8\u5617\u8a66\u57f7\u884c\u7684\u67e5\u8a62\u8d85\u904e\u76ee\u6a19\u5217\u8868\u4e2d\u5141\u8a31\u7684\u6700\u5927\u5217\u6578\u6642\u3002<\/p>\n<p>\u76ee\u6a19\u5217\u8868\u662f SELECT \u8a9e\u53e5\u7684\u4e00\u90e8\u5206\uff0c\u7528\u65bc\u6307\u5b9a\u5728\u67e5\u8a62\u7d50\u679c\u4e2d\u8fd4\u56de\u7684\u5217\u3002\u76ee\u6a19\u5217\u8868\u4e2d\u5141\u8a31\u7684\u6700\u5927\u5217\u6578\u7531 PostgreSQL \u7684\u914d\u7f6e\u53c3\u6578 &#8220;max_columns&#8221; \u6c7a\u5b9a\u3002\u9810\u8a2d\u60c5\u6cc1\u4e0b\uff0c\u6b64\u53c3\u6578\u8a2d\u5b9a\u70ba 1664\u3002<\/p>\n<h2 id=\"causes-of-postgresql-error-code-54011-too_many_columns-ntuBuPjMSL\">PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns \u7684\u539f\u56e0<\/h2>\n<p>\u9047\u5230 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns \u53ef\u80fd\u6709\u4ee5\u4e0b\u5e7e\u500b\u539f\u56e0\uff1a<\/p>\n<ul>\n<li><strong>\u5217\u6578\u904e\u591a\uff1a<\/strong>\u5982\u679c\u60a8\u7684\u67e5\u8a62\u6d89\u53ca\u5927\u91cf\u7684\u76ee\u6a19\u5217\u8868\u4e2d\u7684\u5217\uff0c\u4e26\u4e14\u8d85\u904e\u4e86 &#8220;max_columns&#8221; \u53c3\u6578\u8a2d\u5b9a\u7684\u6700\u5927\u9650\u5236\uff0c\u5247\u6703\u767c\u751f\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u8907\u96dc\u7684\u67e5\u8a62\uff1a<\/strong>\u6d89\u53ca\u8907\u96dc\u7684\u806f\u63a5\u6216\u5b50\u67e5\u8a62\u7684\u67e5\u8a62\u53ef\u80fd\u6703\u5c0e\u81f4\u76ee\u6a19\u5217\u8868\u4e2d\u7684\u5217\u6578\u904e\u591a\uff0c\u5f9e\u800c\u5f15\u767c\u8a72\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h2 id=\"fixing-postgresql-error-code-54011-too_many_columns-ntuBuPjMSL\">\u4fee\u5fa9 PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns<\/h2>\n<p>\u8981\u89e3\u6c7a PostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns\uff0c\u60a8\u53ef\u4ee5\u63a1\u53d6\u4ee5\u4e0b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-reduce-the-number-of-columns-ntuBuPjMSL\">1. \u6e1b\u5c11\u5217\u6578<\/h3>\n<p>\u5982\u679c\u60a8\u7684\u67e5\u8a62\u6d89\u53ca\u5927\u91cf\u5217\uff0c\u8acb\u8003\u616e\u6e1b\u5c11\u76ee\u6a19\u5217\u8868\u4e2d\u7684\u5217\u6578\u3002\u6aa2\u67e5\u60a8\u7684\u67e5\u8a62\uff0c\u78ba\u5b9a\u6240\u6709\u5217\u662f\u5426\u5fc5\u9700\u3002\u522a\u9664\u4efb\u4f55\u4e0d\u5fc5\u8981\u7684\u5217\uff0c\u5c07\u5217\u6578\u63a7\u5236\u5728 &#8220;max_columns&#8221; \u53c3\u6578\u8a2d\u5b9a\u7684\u9650\u5236\u7bc4\u570d\u5167\u3002<\/p>\n<h3 id=\"2-optimize-complex-queries-ntuBuPjMSL\">2. \u512a\u5316\u8907\u96dc\u67e5\u8a62<\/h3>\n<p>\u5982\u679c\u60a8\u7684\u67e5\u8a62\u6d89\u53ca\u8907\u96dc\u7684\u806f\u63a5\u6216\u5b50\u67e5\u8a62\uff0c\u8acb\u5c0d\u5176\u9032\u884c\u512a\u5316\u4ee5\u6e1b\u5c11\u76ee\u6a19\u5217\u8868\u4e2d\u7684\u5217\u6578\u3002\u7c21\u5316\u60a8\u7684\u67e5\u8a62\uff0c\u79fb\u9664\u4e0d\u5fc5\u8981\u7684\u806f\u63a5\u6216\u5b50\u67e5\u8a62\u3002\u8003\u616e\u4f7f\u7528\u81e8\u6642\u8868\u6216\u8996\u5716\uff0c\u5c07\u8907\u96dc\u7684\u67e5\u8a62\u5206\u89e3\u6210\u8f03\u5c0f\u3001\u66f4\u6613\u7ba1\u7406\u7684\u90e8\u5206\u3002<\/p>\n<h3 id=\"3-increase-the-max_columns-parameter-ntuBuPjMSL\">3. \u589e\u52a0 max_columns \u53c3\u6578<\/h3>\n<p>\u5982\u679c\u7121\u6cd5\u6e1b\u5c11\u5217\u6578\u6216\u512a\u5316\u67e5\u8a62\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u589e\u52a0 PostgreSQL \u914d\u7f6e\u4e2d\u7684 &#8220;max_columns&#8221; \u53c3\u6578\u503c\u3002\u7136\u800c\uff0c\u8acb\u6ce8\u610f\u904e\u5ea6\u589e\u52a0\u8a72\u53c3\u6578\u53ef\u80fd\u6703\u5f71\u97ff\u6578\u64da\u5eab\u7684\u6027\u80fd\u3002\u5728\u9032\u884c\u4efb\u4f55\u914d\u7f6e\u66f4\u6539\u4e4b\u524d\uff0c\u5efa\u8b70\u8207\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u6216 PostgreSQL \u5c08\u5bb6\u9032\u884c\u8aee\u8a62\u3002<\/p>\n<h2 id=\"summary-ntuBuPjMSL\">\u7e3d\u7d50<\/h2>\n<p>\u7e3d\u4e4b\uff0cPostgreSQL \u932f\u8aa4\u4ee3\u78bc\uff1a54011 &#8211; too_many_columns \u767c\u751f\u5728\u67e5\u8a62\u8d85\u904e\u76ee\u6a19\u5217\u8868\u4e2d\u5141\u8a31\u7684\u6700\u5927\u5217\u6578\u6642\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u60a8\u53ef\u4ee5\u6e1b\u5c11\u5217\u6578\u3001\u512a\u5316\u8907\u96dc\u67e5\u8a62\u6216\u589e\u52a0 max_columns \u53c3\u6578\u3002\u5982\u679c\u60a8\u5728\u4f7f\u7528 PostgreSQL \u6642\u9047\u5230\u6b64\u932f\u8aa4\uff0c\u8acb\u8003\u616e\u63a1\u53d6\u9069\u7576\u7684\u89e3\u6c7a\u65b9\u6848\u4ee5\u78ba\u4fdd\u6578\u64da\u5eab\u7684\u6b63\u5e38\u904b\u4f5c\u3002<\/p>\n<p>\u5982\u9700\u66f4\u591a\u6709\u95dc VPS \u8a17\u7ba1\u7684\u8cc7\u8a0a\uff0c\u4e26\u63a2\u7d22\u6211\u5011\u53ef\u9760\u4e14\u9ad8\u6548\u80fd\u7684 VPS \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>= \u5982\u4f55\u4fee\u5fa9 PostgreSQ&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-21447","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21447","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21447"}],"version-history":[{"count":2,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21447\/revisions"}],"predecessor-version":[{"id":24035,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21447\/revisions\/24035"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}