{"id":21610,"date":"2024-01-02T12:21:27","date_gmt":"2024-01-02T12:21:27","guid":{"rendered":"https:\/\/server.hk\/blog\/21610\/"},"modified":"2024-11-14T10:29:49","modified_gmt":"2024-11-14T02:29:49","slug":"how-to-fix-mongodb-error-code-15-overflow","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21610\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow"},"content":{"rendered":"<h1 id=\"how-to-fix-mongodb-error-code-15-overflow-apjyhiIGZJ\">\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u53d7\u6b61\u8fce\u7684\u958b\u6e90 NoSQL \u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u9ad8\u6548\u80fd\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u7136\u800c\uff0c\u8207\u4efb\u4f55\u5176\u4ed6\u8edf\u4ef6\u4e00\u6a23\uff0c\u5b83\u53ef\u80fd\u6703\u9047\u5230\u9700\u8981\u89e3\u6c7a\u7684\u932f\u8aa4\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u662f MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6b64\u932f\u8aa4\u7684\u6210\u56e0\uff0c\u4e26\u63d0\u4f9b\u89e3\u6c7a\u65b9\u6848\u4f86\u4fee\u5fa9\u5b83\u3002<\/p>\n<h2 id=\"understanding-mongodb-error-code-15-overflow-apjyhiIGZJ\">\u4e86\u89e3 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow<\/h2>\n<p>\u7576\u6578\u503c\u8d85\u904e\u53ef\u4ee5\u5b58\u5132\u65bc\u5b57\u6bb5\u4e2d\u7684\u6700\u5927\u9650\u5236\u6642\uff0cMongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow \u5c31\u6703\u767c\u751f\u3002\u6b64\u932f\u8aa4\u901a\u5e38\u5728\u57f7\u884c\u6578\u5b78\u64cd\u4f5c\u6216\u63d2\u5165\/\u66f4\u65b0\u5e36\u6709\u6578\u503c\u7684\u6587\u6a94\u6642\u51fa\u73fe\u3002<\/p>\n<p>\u7576\u6b64\u932f\u8aa4\u767c\u751f\u6642\uff0cMongoDB \u6703\u62cb\u51fa\u4e00\u500b\u985e\u4f3c\u5982\u4e0b\u7684\u932f\u8aa4\u8a0a\u606f\uff1a<\/p>\n<pre>\r\nWriteError({\r\n  \"code\" : 15,\r\n  \"errmsg\" : \"Overflow sort stage buffered data usage of 33554434 bytes exceeds internal limit of 33554432 bytes\",\r\n  \"op\" : {\r\n    \"opType\" : \"sort\",\r\n    \"inputStage\" : {\r\n      \"stage\" : \"SORT_KEY_GENERATOR\",\r\n      \"nReturned\" : 0,\r\n      \"executionTimeMillisEstimate\" : 0,\r\n      \"works\" : 1,\r\n      \"advanced\" : 0,\r\n      \"needTime\" : 0,\r\n      \"needYield\" : 0,\r\n      \"saveState\" : 0,\r\n      \"restoreState\" : 0,\r\n      \"isEOF\" : 1,\r\n      \"invalidates\" : 0,\r\n      \"sortPattern\" : {\r\n        \r\n      }\r\n    }\r\n  }\r\n})\r\n<\/pre>\n<h2 id=\"causes-of-mongodb-error-code-15-overflow-apjyhiIGZJ\">MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow \u7684\u6210\u56e0<\/h2>\n<p>\u5c0e\u81f4 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow \u7684\u539f\u56e0\u6709\u5e7e\u500b\uff1a<\/p>\n<ul>\n<li><strong>\u904e\u5927\u7684\u6578\u503c\uff1a<\/strong> \u5982\u679c\u4f60\u8655\u7406\u7684\u6578\u503c\u8d85\u904e\u4e86\u6578\u64da\u985e\u578b\u7684\u6700\u5927\u9650\u5236\uff0cMongoDB \u6703\u62cb\u51fa\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u805a\u5408\u7ba1\u9053\uff1a<\/strong> \u4f7f\u7528\u805a\u5408\u6846\u67b6\u4e26\u5728\u5927\u578b\u6578\u64da\u96c6\u4e0a\u9032\u884c\u6392\u5e8f\u6216\u5206\u7d44\u7b49\u64cd\u4f5c\u6642\uff0c\u4e5f\u53ef\u80fd\u6703\u767c\u751f\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u7d22\u5f15\u5927\u5c0f\uff1a<\/strong> \u5982\u679c\u7d22\u5f15\u5927\u5c0f\u8d85\u904e\u6700\u5927\u9650\u5236\uff0cMongoDB \u5728\u57f7\u884c\u6d89\u53ca\u7d22\u5f15\u7684\u64cd\u4f5c\u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u6b64\u932f\u8aa4\u3002<\/li>\n<\/ul>\n<h2 id=\"fixing-mongodb-error-code-15-overflow-apjyhiIGZJ\">\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow<\/h2>\n<p>\u8981\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow\uff0c\u4f60\u53ef\u4ee5\u5617\u8a66\u4ee5\u4e0b\u89e3\u6c7a\u65b9\u6848\uff1a<\/p>\n<h3 id=\"1-check-numeric-values-apjyhiIGZJ\">1. \u6aa2\u67e5\u6578\u503c<\/h3>\n<p>\u6aa2\u67e5\u6587\u6a94\u4e2d\u7684\u6578\u503c\uff0c\u78ba\u4fdd\u5b83\u5011\u4e0d\u6703\u8d85\u904e\u6578\u64da\u985e\u578b\u7684\u6700\u5927\u9650\u5236\u3002\u5982\u679c\u6709\u5fc5\u8981\uff0c\u8003\u616e\u4f7f\u7528\u66f4\u5927\u7684\u6578\u64da\u985e\u578b\u4f86\u5bb9\u7d0d\u8f03\u5927\u7684\u6578\u503c\u3002<\/p>\n<h3 id=\"2-optimize-aggregation-pipeline-apjyhiIGZJ\">2. \u512a\u5316\u805a\u5408\u7ba1\u9053<\/h3>\n<p>\u5982\u679c\u932f\u8aa4\u5728\u57f7\u884c\u805a\u5408\u7ba1\u9053\u64cd\u4f5c\u6642\u767c\u751f\uff0c\u8acb\u512a\u5316\u4f60\u7684\u7ba1\u9053\u4ee5\u6e1b\u5c11\u5167\u5b58\u4f7f\u7528\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528 $match \u548c $limit \u4f86\u7be9\u9078\u4e26\u6e1b\u5c11\u6578\u64da\u96c6\uff0c\u7136\u5f8c\u518d\u57f7\u884c\u5982\u6392\u5e8f\u6216\u5206\u7d44\u7b49\u6d88\u8017\u8cc7\u6e90\u7684\u64cd\u4f5c\u3002<\/p>\n<h3 id=\"3-reduce-index-size-apjyhiIGZJ\">3. \u6e1b\u5c11\u7d22\u5f15\u5927\u5c0f<\/h3>\n<p>\u5982\u679c\u932f\u8aa4\u8207\u7d22\u5f15\u5927\u5c0f\u6709\u95dc\uff0c\u8003\u616e\u6e1b\u5c11\u7d22\u5f15\u7684\u5927\u5c0f\u3002\u4f60\u53ef\u4ee5\u79fb\u9664\u7d22\u5f15\u4e2d\u4e0d\u5fc5\u8981\u7684\u5b57\u6bb5\uff0c\u6216\u4f7f\u7528\u8907\u5408\u7d22\u5f15\u4f86\u5c07\u591a\u500b\u5b57\u6bb5\u5408\u4f75\u70ba\u4e00\u500b\u7d22\u5f15\u3002<\/p>\n<h3 id=\"4-increase-internal-limit-apjyhiIGZJ\">4. \u589e\u52a0\u5167\u90e8\u9650\u5236<\/h3>\n<p>\u5982\u679c\u4e0a\u8ff0\u89e3\u6c7a\u65b9\u6848\u5747\u7121\u6548\uff0c\u4f60\u53ef\u4ee5\u5617\u8a66\u589e\u52a0\u89f8\u767c\u932f\u8aa4\u7684\u7279\u5b9a\u64cd\u4f5c\u7684\u5167\u90e8\u9650\u5236\u3002\u7136\u800c\uff0c\u6b64\u64cd\u4f5c\u61c9\u8b39\u614e\u9032\u884c\uff0c\u56e0\u70ba\u5b83\u53ef\u80fd\u6703\u5c0d\u5167\u5b58\u4f7f\u7528\u548c\u6027\u80fd\u7522\u751f\u5f71\u97ff\u3002<\/p>\n<h2 id=\"summary-apjyhiIGZJ\">\u7e3d\u7d50<\/h2>\n<p>\u7576\u6578\u503c\u8d85\u904e\u53ef\u4ee5\u5b58\u5132\u65bc\u5b57\u6bb5\u4e2d\u7684\u6700\u5927\u9650\u5236\u6642\uff0cMongoDB \u932f\u8aa4\u4ee3\u78bc &#8211; 15 &#8211; Overflow \u6703\u767c\u751f\u3002\u8981\u4fee\u5fa9\u6b64\u932f\u8aa4\uff0c\u4f60\u9700\u8981\u6aa2\u67e5\u4f60\u7684\u6578\u503c\u3001\u512a\u5316\u805a\u5408\u7ba1\u9053\u64cd\u4f5c\u3001\u6e1b\u5c11\u7d22\u5f15\u5927\u5c0f\uff0c\u6216\u8005\u589e\u52a0\u5167\u90e8\u9650\u5236\u3002\u5982\u679c\u9047\u5230\u6b64\u932f\u8aa4\uff0c\u8acb\u8003\u616e\u9075\u5faa\u9019\u4e9b\u89e3\u6c7a\u65b9\u6848\uff0c\u4ee5\u78ba\u4fdd MongoDB \u6578\u64da\u5eab\u7684\u9806\u66a2\u904b\u884c\u3002<\/p>\n<p>\u5982\u9700\u7a69\u5b9a\u4e14\u9ad8\u6548\u80fd\u7684 VPS \u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8003\u616e <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002\u6211\u5011\u7684\u8a17\u7ba1\u670d\u52d9\u65e8\u5728\u6eff\u8db3\u5404\u985e\u578b\u4f01\u696d\u7684\u9700\u6c42\uff0c\u63d0\u4f9b\u5353\u8d8a\u7684\u6548\u80fd\u548c\u53ef\u64f4\u5c55\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u4ee3&#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-21610","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21610","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=21610"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21610\/revisions"}],"predecessor-version":[{"id":23820,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21610\/revisions\/23820"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}