用于对BIG集合进行过滤和排序的Mongodb复合索引 [英] Mongodb compound indexes for filtering and sorting on BIG collection

查看:117
本文介绍了用于对BIG集合进行过滤和排序的Mongodb复合索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我在这种情况下是否可以使Mongodb中的索引更有效:我的数据库有5000万个项目.在字段"ico"和"publishDate"上有两个索引. Ico用于过滤,而publishDate用于排序.是否有可能使它像化合物索引一样更有效?我可以在复合索引中结合过滤和排序吗?选择索引定义中的第一个应该重要吗?这有点复杂,因为我没有本地主机上的集合.

Can somebody tell me please if is possible to make indexes in Mongodb more efficient in this case: I have database with 50 millions items. There are two indexes on fields "ico" and "publishDate". Ico is used for filtering and publishDate for sorting. Is it possible to make it like a compound index to be more efficient? Can I combine filtering and sorting in compound index? Is important to choose which one should be the first in index definition? It is little complicated cause I have not the collection on localhost.

推荐答案

将复合索引创建为{ico: 1, publishDate: 1}.请参考文档.

Create a compound index as {ico: 1, publishDate: 1}. Refer to doc.

这篇关于用于对BIG集合进行过滤和排序的Mongodb复合索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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