Live data from Hacker News

Optimizing MongoDB Compound Indexes

emptysquare.net

11–12 of 12 posts

Re: Optimizing MongoDB Compound Indexes

#11
post #3

Earlier quoted context omitted.

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.

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.

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

#12
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).

Post reply on HN