News for hackers. Stuff that matters.
Re:Optimizing MongoDB Compound Indexes by Loic on Tuesday October 09, 2012 @07:18AM (#4630923)
About 2 years ago (time is flying) I explained how I did the same to support range queries over "n" attributes, the method ended up being in the book "MongoDB, the Definitive Guide" by Chodorow and Dirolf (O'Reilly):

http://chemeo.com/doc/technology

(Search for "Indexing For High Speed Search" to skip non MongoDB related information).

Re:Optimizing MongoDB Compound Indexes by dkhenry on Monday October 08, 2012 @04:30PM (#4628622)
What should be added to this is the ability to tell Mongo to return an error if your query requires a table scan. That one configuration item can be the difference between a request returning an error and a whole site going down for an extended period.
Re:Optimizing MongoDB Compound Indexes by pbrumm on Monday October 08, 2012 @05:00PM (#4628715)
There is a config setting for that

  notablescan = true
http://docs.mongodb.org/manual/reference/configuration-optio...
Re:Optimizing MongoDB Compound Indexes by dkhenry on Monday October 08, 2012 @05:22PM (#4628799)
Right I was saying that the author should add that to his article. Its a very valuable configuration item and anytime your dealing with optimizing indexes its worth enabling.
Re:Optimizing MongoDB Compound Indexes by lucian1900 on Monday October 08, 2012 @04:45PM (#4628670)
You can ask it to explain what it did, just like you'd ask for the last error. Then in your app enforce whatever rules related to indexes you wish.
Re:Optimizing MongoDB Compound Indexes by mattparlane on Monday October 08, 2012 @04:52PM (#4628691)
explain actually runs the query. From http://www.mongodb.org/display/DOCS/Explain :

    Note that explain runs the actual query to determine the result. If the query is slow, the explain will be slow too.
Re:Optimizing MongoDB Compound Indexes by MartinMond on Monday October 08, 2012 @02:34PM (#4628169)
Is MongoDB actually able to combine 2 or more indices?
Re:Optimizing MongoDB Compound Indexes by jiryu on Monday October 08, 2012 @02:38PM (#4628182)
No - it can only use one for a given query. But a compound index like the ones I describe in the post can index many fields.
Re:Optimizing MongoDB Compound Indexes by MartinMond on Monday October 08, 2012 @02:42PM (#4628202)
Yes of course, but it's kinda slow if you have to maintain one compound index for each possible query you're going to run, that's why I was asking.
Re:Optimizing MongoDB Compound Indexes by chmod775 on Monday October 08, 2012 @11:55PM (#4629878)
Nope, you can use the compound index 'a,b,c' to query over the following fields:

    a
    a.b
    a,b,c
The manual actually explains it like that.
Re:Optimizing MongoDB Compound Indexes by mattparlane on Monday October 08, 2012 @03:10PM (#4628335)
You may be interested in this:

https://jira.mongodb.org/browse/SERVER-3071

It's index intersection, and it's scheduled for 2.3.1 which is the next next dev release. I'm hoping it makes it in for 2.4.