I
I
Imbolc2012-03-06 09:03:13
MongoDB
Imbolc, 2012-03-06 09:03:13

mongodb indexes?

What indexes should be for such a query?

db.foo.find({
        $or : [ { a : 1 } , { b : 2 } ],
        c: {$lte: 3}
    }).sort( { c : -1 } )

I tried to test it, but I don't see an unambiguous dependence of speed on indexing for individual fields or for all together. Whether have in general sense indexes on many fields. Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2012-03-06
@akalend

> Whether indexes on many fields
have in general sense, if only on these fields there is a search. Example db.user.find({city:'Moscow', sex:0, age:18})
building a composite index on the fields city,sex,age

S
sermal, 2012-03-07
@sermal

Definitely need db.foo.ensureIndex({c:1})
Then create a large test set and use explain.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question