有了新的索引交集功能,什么时候复合索引在MongoDB 2.6中仍然有用? [英] When are Compound Indexes still relevant in MongoDB 2.6, given the new Index Intersection feature?

查看:100
本文介绍了有了新的索引交集功能,什么时候复合索引在MongoDB 2.6中仍然有用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mongo 2.6引入了索引交集.在我看来,使用复合索引可以实现任何目标,使用索引交集可以更轻松地实现任何目标,并且具有更大的灵活性(因为它可以支持更多类型的查询). 但是,Mongo的文档说:

Mongo 2.6 introduced Index Intersection. It appears to me that whatever can be achieved using Compound Index, can be more easily achieved using Index Intersection, and with greater flexibility (as it could support more types of queries). However, Mongo's documentation says that:

索引交集并不能消除创建复合索引的需要. (链接)

然后继续说明相对于索引交集使用复合索引的缺点.我不明白使用这种索引而不是让mongo与多个索引相交以完成查询的优点是什么.

Then it goes on explaining the disadvantages of using compound index relatively to index intersection. I could not understand what is the advantage of using such index instead of letting mongo intersect several indexes to fulfill the query.

编辑:我建议阅读

Edit: I recommended reading the link @Sammaye provided in his answer for detailed explanation of index intersection vs. compound index by Mongo's dev David Storch. Bottom line:

索引交集不应被视为复合索引的替代

index intersection should not be considered a replacement for compound indices

推荐答案

有两点需要回答:

索引交集默认情况下处于启用状态.尽管将来此限制可能会增加,但查询计划程序当前一次只能将其限制为2个索引.

Index intersection is on by default. The query planner currently limits itself to 2 indices at a time, though this limit may increase in the future.

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆