索引交点与复合索引? [英] Index intersection vs. compound index?

查看:88
本文介绍了索引交点与复合索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我不完全理解索引交集和使用复合索引之间的一些区别.

So, I don't fully understand some distinctions between index intersection and using compound indexes.

mongodb是否有可能在每个查询中使用多个索引交集?复合索引和索引交集之间的性能差异是什么?

Is it possible for mongodb to use multiple index intersections per query? What is the performance difference between compound indexes and index intersection?

推荐答案

mongodb是否有可能在每个查询中使用多个索引交集?

Is it possible for mongodb to use multiple index intersections per query?

索引交集是MongoDB 2.5.5开发版本中引入的一项新功能,并将包含在MongoDB 2.6生产版本中.

Index intersection is a new feature introduced in the MongoDB 2.5.5 development build, and will be included in the MongoDB 2.6 production release.

索引交集涉及使用多个索引来满足查询;复合索引是多个字段上的索引.索引交集可以使用整个索引或复合索引的索引前缀.通常,从MongoDB 2.5.5开始,每个索引交集涉及两个索引;但是,MongoDB可以使用多个/嵌套索引交集来解决查询.

Index intersection involves the use of multiple indexes to satisfy a query; compound indexes are indexes on multiple fields. It is possible for index intersection to use either an entire index or an index prefix of a compound index. In general, as at MongoDB 2.5.5 each index intersection involves two indexes; however, MongoDB can employ multiple/nested index intersections to resolve a query.

复合索引和索引交集之间的性能差异是什么?

What is the performance difference between compound indexes and index intersection?

这将根据您的用例而有所不同.如果没有合适的复合索引来覆盖所有常见查询,则索引交集会提供灵活性,但是复合索引可能更具选择性,并且能够通过检查较少的索引条目来查找结果.相反,如果您能够利用索引交集来替换多个复合索引,则可能会减少索引维护的开销.

This is going to vary based on your use case. Index intersection provides flexibility if there isn't a suitable compound index to cover all of your common queries, but a compound index may be more selective and be able to find results inspecting fewer index entries. Conversely, if you are able to take advantage of index intersection to replace multiple compound indexes there may be benefits of reduced overhead for index maintenance.

您最好的方法是在开发/登台环境中对此进行测试.

Your best approach is to test this in your development/staging environment.

手册中有一个索引相交页,其中有一些内容有关其工作原理的更多详细信息.

There is an Index Intersection page in the manual which goes into some more detail on how this works.

这篇关于索引交点与复合索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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