You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
index on some field sort descending/ascending issue #3
Thanks for your question. There are a few situations where the order does matter, such as when you have a compound orderby clause combined with other factors (such as a query, with a return limit, on field A, ordered by { B: -1, C: 1}). For this and similar examples, an index on { A: 1, B: -1, C: 1 } should perform slightly more quickly and with slightly less memory used, because of a lefthanded optimization within the MongoDB index structure.
Right now, Dex blindly recommends ascending order for all indexes.
For your specific index, there is indeed not much difference in the order chosen. That said, I'd like to explore ways to include something about this in Dex's heuristics for generating recommendations!
Activity
shoujs commentedon Aug 24, 2012
after reading the answers in stackoverflow, i understand that the index works for both ascending and descending cases.
esedor commentedon Sep 5, 2012
Hi!
Thanks for your question. There are a few situations where the order does matter, such as when you have a compound orderby clause combined with other factors (such as a query, with a return limit, on field A, ordered by { B: -1, C: 1}). For this and similar examples, an index on { A: 1, B: -1, C: 1 } should perform slightly more quickly and with slightly less memory used, because of a lefthanded optimization within the MongoDB index structure.
Right now, Dex blindly recommends ascending order for all indexes.
For your specific index, there is indeed not much difference in the order chosen. That said, I'd like to explore ways to include something about this in Dex's heuristics for generating recommendations!