We have implemented a limited fix for MongoDB2.2 and 2.4 limited fixes in version 2.2. The following query statement will work as you wish and return the result within milliseconds: db. posts. find ({userId :{$ in: [12, 24, 56,…]}). Sort ({date:-1}). limit (-100) So you may have thought this was perfect ...... Unfortunately
MongoDB 2.2 and 2.4 limited fixes 2.2. The following query statement returns the result in milliseconds as you wish: db. posts. find ({userId: {$ in: [12, 24, 56,…] }). Sort ({date:-1}). limit (-100) So you may think this is perfect ...... Unfortunately
Limited fixes for MongoDB 2.2 and 2.4
Version 2.2 provides a limited solution. The following query statement will work as you wish and return results within milliseconds:
Db. posts. find ({userId: {$ in: [12, 24, 56,…] }). Sort ({date:-1}). limit (-100)
So you may think that this is perfect ...... Unfortunately, there is a major limitation that any extra predicate will disable the optimization mechanism. Any extra predicate must be an equation (or "$ in") on a field. This field is part of the index and is located in the index field ("date" in this example). to the left. If you want to see the posts of a specific attribute (for example, "private: False"), you must be careful when constructing the index:
Db. posts. find ({userId: {$ in: [12, 24, 56,…], Private: False }}). sort ({date:-1}). limit (-100)
It must open the index above "{userId: 1, private: 1, date: 1. Some different types of predicate assertions, or the opposite field is not covered by the correct part of the index, so this will bring you back to the very bad and slow situation.
This problem will be solved by rebuilding the internal API of index 2.6, which should be exactly what you expect!