{"id":21549,"date":"2024-01-02T11:19:26","date_gmt":"2024-01-02T11:19:26","guid":{"rendered":"https:\/\/server.hk\/blog\/21549\/"},"modified":"2024-11-14T10:30:54","modified_gmt":"2024-11-14T02:30:54","slug":"mongodb-glossary-index-intersection","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21549\/","title":{"rendered":"MongoDB \u8a5e\u5f59\u8868 &#8211; \u7d22\u5f15\u4ea4\u96c6"},"content":{"rendered":"<h1 id=\"mongodb-glossary-index-intersection-lMpizmglsO\">MongoDB \u8a5e\u5f59\u8868 &#8211; \u7d22\u5f15\u4ea4\u96c6<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7684\u4e16\u754c\u4e2d\uff0c\u7531\u65bc\u5176\u9748\u6d3b\u6027\u3001\u53ef\u64f4\u5c55\u6027\u548c\u6027\u80fd\uff0cMongoDB \u7372\u5f97\u4e86\u986f\u8457\u7684\u666e\u53ca\u3002\u4fc3\u9032\u5176\u6548\u7387\u7684\u95dc\u9375\u7279\u6027\u4e4b\u4e00\u5c31\u662f\u7d22\u5f15\u4ea4\u96c6\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u4ec0\u9ebc\u662f\u7d22\u5f15\u4ea4\u96c6\uff0c\u4ee5\u53ca\u5b83\u5982\u4f55\u63d0\u5347\u60a8\u7684 MongoDB \u6578\u64da\u5eab\u7684\u6027\u80fd\u3002<\/p>\n<h2 id=\"understanding-indexes-in-mongodb-lMpizmglsO\">\u7406\u89e3 MongoDB \u4e2d\u7684\u7d22\u5f15<\/h2>\n<p>\u7d22\u5f15\u5728\u63d0\u9ad8\u6578\u64da\u5eab\u67e5\u8a62\u6027\u80fd\u65b9\u9762\u626e\u6f14\u8457\u81f3\u95dc\u91cd\u8981\u7684\u89d2\u8272\u3002\u5b83\u5011\u662f\u6578\u64da\u7d50\u69cb\uff0c\u5141\u8a31\u6578\u64da\u5eab\u6839\u64da\u67d0\u4e9b\u5b57\u6bb5\u7684\u503c\u5feb\u901f\u5b9a\u4f4d\u548c\u6aa2\u7d22\u7279\u5b9a\u6587\u6a94\u3002\u5982\u679c\u6c92\u6709\u7d22\u5f15\uff0cMongoDB \u5c07\u4e0d\u5f97\u4e0d\u6383\u63cf\u96c6\u5408\u4e2d\u7684\u6bcf\u500b\u6587\u6a94\u4f86\u67e5\u627e\u6240\u9700\u7684\u6578\u64da\uff0c\u9019\u6703\u5c0e\u81f4\u67e5\u8a62\u57f7\u884c\u8b8a\u6162\u3002<\/p>\n<p>MongoDB \u652f\u6301\u5404\u7a2e\u985e\u578b\u7684\u7d22\u5f15\uff0c\u5305\u62ec\u55ae\u5b57\u6bb5\u7d22\u5f15\u3001\u5fa9\u5408\u7d22\u5f15\u3001\u591a\u9375\u7d22\u5f15\u548c\u5730\u7406\u7a7a\u9593\u7d22\u5f15\u3002\u9019\u4e9b\u7d22\u5f15\u53ef\u4ee5\u901a\u904e\u6e1b\u5c11\u9700\u8981\u6383\u63cf\u7684\u6578\u64da\u91cf\u4f86\u986f\u8457\u52a0\u5feb\u67e5\u8a62\u57f7\u884c\u901f\u5ea6\u3002<\/p>\n<h2 id=\"what-is-index-intersection-lMpizmglsO\">\u4ec0\u9ebc\u662f\u7d22\u5f15\u4ea4\u96c6\uff1f<\/h2>\n<p>\u7d22\u5f15\u4ea4\u96c6\u662f MongoDB \u4e2d\u7684\u4e00\u500b\u7279\u6027\uff0c\u5141\u8a31\u6578\u64da\u5eab\u7d50\u5408\u591a\u500b\u7d22\u5f15\u4f86\u6eff\u8db3\u67e5\u8a62\u3002\u5b83\u4f7f MongoDB \u80fd\u5920\u4f7f\u7528\u591a\u500b\u7d22\u5f15\u4f86\u9ad8\u6548\u6aa2\u7d22\u6240\u9700\u6578\u64da\u3002\u9019\u4e00\u7279\u6027\u5728\u67e5\u8a62\u6d89\u53ca\u591a\u500b\u5b57\u6bb5\u4e14\u6bcf\u500b\u5b57\u6bb5\u90fd\u6709\u81ea\u5df1\u7684\u7d22\u5f15\u6642\u7279\u5225\u6709\u7528\u3002<\/p>\n<p>\u7576\u67e5\u8a62\u88ab\u57f7\u884c\u6642\uff0cMongoDB \u7684\u67e5\u8a62\u512a\u5316\u5668\u6703\u5206\u6790\u8a72\u67e5\u8a62\u4e26\u78ba\u5b9a\u6700\u6709\u6548\u7684\u7d22\u5f15\u4f86\u4f7f\u7528\u3002\u5982\u679c\u67e5\u8a62\u6d89\u53ca\u591a\u500b\u5b57\u6bb5\uff0c\u512a\u5316\u5668\u53ef\u4ee5\u9078\u64c7\u4f7f\u7528\u7d22\u5f15\u4ea4\u96c6\u4f86\u7d50\u5408\u7d22\u5f15\uff0c\u4e26\u66f4\u9ad8\u6548\u5730\u6aa2\u7d22\u6578\u64da\u3002<\/p>\n<h2 id=\"benefits-of-index-intersection-lMpizmglsO\">\u7d22\u5f15\u4ea4\u96c6\u7684\u597d\u8655<\/h2>\n<p>\u7d22\u5f15\u4ea4\u96c6\u63d0\u4f9b\u4e86\u5e7e\u500b\u53ef\u4ee5\u986f\u8457\u6539\u5584\u60a8\u7684 MongoDB \u6578\u64da\u5eab\u6027\u80fd\u7684\u597d\u8655\uff1a<\/p>\n<ul>\n<li><strong>\u6539\u5584\u67e5\u8a62\u6027\u80fd\uff1a<\/strong>\u901a\u904e\u7d50\u5408\u591a\u500b\u7d22\u5f15\uff0cMongoDB \u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u6aa2\u7d22\u6240\u9700\u6578\u64da\uff0c\u5f9e\u800c\u52a0\u5feb\u67e5\u8a62\u57f7\u884c\u901f\u5ea6\u3002<\/li>\n<li><strong>\u6e1b\u5c11\u78c1\u789f\u7a7a\u9593\uff1a<\/strong>\u7d22\u5f15\u4ea4\u96c6\u5141\u8a31 MongoDB \u4f7f\u7528\u73fe\u6709\u7d22\u5f15\uff0c\u800c\u4e0d\u662f\u5275\u5efa\u65b0\u7684\u7d22\u5f15\uff0c\u5f9e\u800c\u6e1b\u5c11\u5b58\u5132\u7d22\u5f15\u6240\u9700\u7684\u78c1\u789f\u7a7a\u9593\u3002<\/li>\n<li><strong>\u9748\u6d3b\u6027\uff1a<\/strong>\u7d22\u5f15\u4ea4\u96c6\u901a\u904e\u5141\u8a31\u60a8\u5728\u55ae\u500b\u5b57\u6bb5\u4e0a\u5275\u5efa\u7d22\u5f15\uff0c\u800c\u4e0d\u5fc5\u64d4\u5fc3\u5fa9\u5408\u7d22\u5f15\u4e2d\u5b57\u6bb5\u7684\u9806\u5e8f\uff0c\u63d0\u4f9b\u4e86\u67e5\u8a62\u8a2d\u8a08\u7684\u9748\u6d3b\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"example-of-index-intersection-lMpizmglsO\">\u7d22\u5f15\u4ea4\u96c6\u793a\u4f8b<\/h2>\n<p>\u8b93\u6211\u5011\u8003\u616e\u4e00\u500b\u793a\u4f8b\u4f86\u7406\u89e3\u7d22\u5f15\u4ea4\u96c6\u662f\u5982\u4f55\u904b\u4f5c\u7684\u3002\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u540d\u70ba\u300cusers\u300d\u7684 MongoDB \u96c6\u5408\uff0c\u4e26\u4e14\u6709\u5169\u500b\u7d22\u5f15\uff1a\u4e00\u500b\u5728\u300cname\u300d\u5b57\u6bb5\u4e0a\uff0c\u53e6\u4e00\u500b\u5728\u300cage\u300d\u5b57\u6bb5\u4e0a\u3002\u73fe\u5728\uff0c\u5982\u679c\u6211\u5011\u57f7\u884c\u4e00\u500b\u67e5\u8a62\u4f86\u67e5\u627e\u6240\u6709\u7279\u5b9a\u540d\u7a31\u548c\u5e74\u9f61\u7684\u7528\u6236\uff0cMongoDB \u53ef\u4ee5\u4f7f\u7528\u7d22\u5f15\u4ea4\u96c6\u4f86\u7d50\u5408\u9019\u5169\u500b\u7d22\u5f15\uff0c\u4e26\u9ad8\u6548\u5730\u6aa2\u7d22\u6578\u64da\u3002<\/p>\n<pre><code>db.users.find({ name: \"John\", age: 30 })\r\n<\/code><\/pre>\n<p>\u5728\u9019\u7a2e\u60c5\u6cc1\u4e0b\uff0cMongoDB \u7684\u67e5\u8a62\u512a\u5316\u5668\u53ef\u4ee5\u5229\u7528\u300cname\u300d\u7d22\u5f15\u548c\u300cage\u300d\u7d22\u5f15\u4f86\u6aa2\u7d22\u6240\u9700\u6578\u64da\uff0c\u5f9e\u800c\u6539\u5584\u67e5\u8a62\u6027\u80fd\u3002<\/p>\n<h2 id=\"summary-lMpizmglsO\">\u7e3d\u7d50<\/h2>\n<p>\u7d22\u5f15\u4ea4\u96c6\u662f MongoDB \u4e2d\u4e00\u500b\u5f37\u5927\u7684\u7279\u6027\uff0c\u5141\u8a31\u6578\u64da\u5eab\u7d50\u5408\u591a\u500b\u7d22\u5f15\u4f86\u589e\u5f37\u67e5\u8a62\u6027\u80fd\u3002\u901a\u904e\u5229\u7528\u7d22\u5f15\u4ea4\u96c6\uff0cMongoDB \u53ef\u4ee5\u9ad8\u6548\u5730\u6aa2\u7d22\u6d89\u53ca\u591a\u500b\u5b57\u6bb5\u7684\u6578\u64da\uff0c\u5f9e\u800c\u52a0\u5feb\u67e5\u8a62\u57f7\u884c\u901f\u5ea6\u3002\u5982\u679c\u60a8\u5e0c\u671b\u512a\u5316 MongoDB \u6578\u64da\u5eab\u7684\u6027\u80fd\uff0c\u8003\u616e\u5229\u7528\u7d22\u5f15\u4ea4\u96c6\u4f86\u6539\u5584\u67e5\u8a62\u97ff\u61c9\u6642\u9593\u3002<\/p>\n<p>\u6709\u95dc MongoDB \u53ca\u5176\u529f\u80fd\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u8003\u616e\u63a2\u7d22 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u9019\u662f\u4e00\u5bb6\u63d0\u4f9b\u53ef\u9760\u548c\u53ef\u64f4\u5c55\u8a17\u7ba1\u89e3\u6c7a\u65b9\u6848\u7684\u9818\u5148 VPS \u8a17\u7ba1\u516c\u53f8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB \u8a5e\u5f59\u8868 &#038;#82&#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-21549","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21549","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=21549"}],"version-history":[{"count":2,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21549\/revisions"}],"predecessor-version":[{"id":23904,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21549\/revisions\/23904"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}