{"id":63638,"date":"2024-10-14T01:13:23","date_gmt":"2024-10-13T17:13:23","guid":{"rendered":"https:\/\/server.hk\/cnblog\/63638\/"},"modified":"2024-10-14T01:13:23","modified_gmt":"2024-10-13T17:13:23","slug":"mongodb-2-0%e6%96%b0%e5%8a%9f%e8%83%bd%e9%80%90%e5%80%8b%e7%9c%8b%e4%b9%8bcompact-command","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/63638\/","title":{"rendered":"MongoDB 2.0\u65b0\u529f\u80fd\u9010\u500b\u770b\u4e4bCompact Command"},"content":{"rendered":"<h1 id=\"mongodb-2-0%e6%96%b0%e5%8a%9f%e8%83%bd%e9%80%90%e5%80%8b%e7%9c%8b%e4%b9%8bcompact-command-YQkidBzunD\">MongoDB 2.0\u65b0\u529f\u80fd\u9010\u500b\u770b\u4e4bCompact Command<\/h1>\n<p>MongoDB\u662f\u4e00\u500b\u6d41\u884c\u7684NoSQL\u6578\u64da\u5eab\uff0c\u56e0\u5176\u9748\u6d3b\u7684\u6578\u64da\u6a21\u578b\u548c\u9ad8\u6548\u7684\u67e5\u8a62\u6027\u80fd\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u96a8\u8457\u7248\u672c\u7684\u66f4\u65b0\uff0cMongoDB\u4e0d\u65b7\u5f15\u5165\u65b0\u529f\u80fd\u4ee5\u63d0\u5347\u5176\u6027\u80fd\u548c\u53ef\u7528\u6027\u3002\u5728MongoDB 2.0\u7248\u672c\u4e2d\uff0cCompact Command\u662f\u4e00\u500b\u91cd\u8981\u7684\u65b0\u529f\u80fd\uff0c\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5176\u7279\u9ede\u53ca\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n<h2 id=\"compact-command%e7%9a%84%e6%a6%82%e8%bf%b0-YQkidBzunD\">Compact Command\u7684\u6982\u8ff0<\/h2>\n<p>Compact Command\u7684\u4e3b\u8981\u76ee\u7684\u662f\u6e1b\u5c11\u6578\u64da\u5eab\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u5f9e\u800c\u63d0\u9ad8\u6027\u80fd\u3002\u96a8\u8457\u6578\u64da\u7684\u589e\u9577\uff0cMongoDB\u7684\u6578\u64da\u6587\u4ef6\u53ef\u80fd\u6703\u8b8a\u5f97\u788e\u7247\u5316\uff0c\u9019\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\u548c\u5b58\u5132\u6548\u7387\u3002Compact Command\u901a\u904e\u91cd\u65b0\u7d44\u7e54\u6578\u64da\u6587\u4ef6\uff0c\u6d88\u9664\u7a7a\u9593\u788e\u7247\uff0c\u4f86\u9054\u5230\u512a\u5316\u7684\u6548\u679c\u3002<\/p>\n<h2 id=\"compact-command%e7%9a%84%e5%b7%a5%e4%bd%9c%e5%8e%9f%e7%90%86-YQkidBzunD\">Compact Command\u7684\u5de5\u4f5c\u539f\u7406<\/h2>\n<p>Compact Command\u7684\u5de5\u4f5c\u539f\u7406\u76f8\u5c0d\u7c21\u55ae\u3002\u7576\u57f7\u884c\u6b64\u547d\u4ee4\u6642\uff0cMongoDB\u6703\u5c0d\u6307\u5b9a\u7684\u6578\u64da\u5eab\u6216\u96c6\u5408\u9032\u884c\u58d3\u7e2e\uff0c\u4e26\u5c07\u6578\u64da\u91cd\u65b0\u5beb\u5165\u78c1\u789f\u3002\u9019\u500b\u904e\u7a0b\u5305\u62ec\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li>\u8b80\u53d6\u7576\u524d\u6578\u64da\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u6578\u64da\u3002<\/li>\n<li>\u5c07\u6578\u64da\u9032\u884c\u6574\u7406\uff0c\u6d88\u9664\u7a7a\u9593\u788e\u7247\u3002<\/li>\n<li>\u5c07\u6574\u7406\u5f8c\u7684\u6578\u64da\u5beb\u5165\u65b0\u7684\u6578\u64da\u6587\u4ef6\u3002<\/li>\n<li>\u66ff\u63db\u820a\u7684\u6578\u64da\u6587\u4ef6\uff0c\u4e26\u91cb\u653e\u4e0d\u518d\u4f7f\u7528\u7684\u7a7a\u9593\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8compact-command-YQkidBzunD\">\u5982\u4f55\u4f7f\u7528Compact Command<\/h2>\n<p>\u4f7f\u7528Compact Command\u975e\u5e38\u7c21\u55ae\uff0c\u53ea\u9700\u5728MongoDB\u7684shell\u4e2d\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>db.runCommand({ compact: \"collectionName\" })<\/code><\/pre>\n<p>\u5728\u9019\u88e1\uff0c<code>collectionName<\/code>\u662f\u60a8\u5e0c\u671b\u58d3\u7e2e\u7684\u96c6\u5408\u540d\u7a31\u3002\u57f7\u884c\u6b64\u547d\u4ee4\u5f8c\uff0cMongoDB\u5c07\u958b\u59cb\u58d3\u7e2e\u904e\u7a0b\uff0c\u4e26\u5728\u5b8c\u6210\u5f8c\u8fd4\u56de\u7d50\u679c\u3002<\/p>\n<h2 id=\"compact-command%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-YQkidBzunD\">Compact Command\u7684\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u96d6\u7136Compact Command\u80fd\u5920\u6709\u6548\u6e1b\u5c11\u6578\u64da\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u4f46\u5728\u4f7f\u7528\u6642\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u57f7\u884cCompact Command\u6642\uff0c\u8a72\u96c6\u5408\u5c07\u88ab\u9396\u5b9a\uff0c\u9019\u53ef\u80fd\u6703\u5f71\u97ff\u5230\u5176\u4ed6\u64cd\u4f5c\u7684\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u5efa\u8b70\u5728\u4f4e\u5cf0\u6642\u6bb5\u57f7\u884c\u6b64\u547d\u4ee4\u3002<\/li>\n<li>\u58d3\u7e2e\u904e\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u5b9a\u7684\u6642\u9593\uff0c\u5177\u9ad4\u53d6\u6c7a\u65bc\u6578\u64da\u7684\u5927\u5c0f\u548c\u788e\u7247\u5316\u7a0b\u5ea6\u3002<\/li>\n<li>\u5728\u57f7\u884cCompact Command\u4e4b\u524d\uff0c\u5efa\u8b70\u5148\u5099\u4efd\u6578\u64da\uff0c\u4ee5\u9632\u6b62\u610f\u5916\u60c5\u6cc1\u5c0e\u81f4\u6578\u64da\u4e1f\u5931\u3002<\/li>\n<\/ul>\n<h2 id=\"compact-command%e7%9a%84%e5%84%aa%e5%8b%a2-YQkidBzunD\">Compact Command\u7684\u512a\u52e2<\/h2>\n<p>\u4f7f\u7528Compact Command\u7684\u4e3b\u8981\u512a\u52e2\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u63d0\u9ad8\u67e5\u8a62\u6027\u80fd\uff1a\u901a\u904e\u6e1b\u5c11\u788e\u7247\u5316\uff0c\u67e5\u8a62\u6027\u80fd\u5c07\u5f97\u5230\u986f\u8457\u63d0\u5347\u3002<\/li>\n<li>\u7bc0\u7701\u5b58\u5132\u7a7a\u9593\uff1a\u58d3\u7e2e\u6578\u64da\u6587\u4ef6\u5f8c\uff0c\u53ef\u4ee5\u7bc0\u7701\u78c1\u789f\u7a7a\u9593\uff0c\u964d\u4f4e\u5b58\u5132\u6210\u672c\u3002<\/li>\n<li>\u6539\u5584\u6578\u64da\u7ba1\u7406\uff1a\u5b9a\u671f\u4f7f\u7528Compact Command\u53ef\u4ee5\u5e6b\u52a9\u7dad\u6301\u6578\u64da\u5eab\u7684\u5065\u5eb7\u72c0\u614b\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-YQkidBzunD\">\u7e3d\u7d50<\/h2>\n<p>MongoDB 2.0\u4e2d\u7684Compact Command\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u512a\u5316\u6578\u64da\u5eab\u6027\u80fd\u548c\u5b58\u5132\u6548\u7387\u3002\u901a\u904e\u5b9a\u671f\u57f7\u884c\u6b64\u547d\u4ee4\uff0c\u7528\u6236\u53ef\u4ee5\u6709\u6548\u7ba1\u7406\u6578\u64da\u5eab\u7684\u788e\u7247\u5316\u554f\u984c\uff0c\u5f9e\u800c\u63d0\u5347\u6574\u9ad4\u6027\u80fd\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u4f86\u904b\u884c\u60a8\u7684MongoDB\u5be6\u4f8b\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u61c9\u7528\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22MongoDB 2.0\u7684\u65b0\u529f\u80fdCompact Command\uff0c\u4e86\u89e3\u5982\u4f55\u4f18\u5316\u5b58\u50a8\u548c\u63d0\u5347\u6027\u80fd\uff0c\u63d0\u5347\u6570\u636e\u5e93\u7ba1\u7406\u6548\u7387\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-63638","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63638","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=63638"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63638\/revisions"}],"predecessor-version":[{"id":63639,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/63638\/revisions\/63639"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=63638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=63638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=63638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}