Mongodb compound indexes for filtering and sorting on BIG collection

∥☆過路亽.° 提交于 2019-12-25 01:11:01

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/54748271/mongodb-compound-indexes-for-filtering-and-sorting-on-big-collection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!