--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
If you have a compound index on multiple fields, you can use it to query on the beginning subset of fields. So if you have an index on
a,b,c
you can use it query on
a
a,b
a,b,c
> > > > > mongodb-user+unsubscribe@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/mongodb-user?hl=en.
>
> > > > --
> > > > Best regards,
> > > > Sergei Tulentsev
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mongodb-user+unsubscribe@googlegroups.com.
The most efficient way for the query with the flag is likely an index on flag, date.
An index on date, flag will be better than no index likely slower than the first. How much slower depends on how selective the field is. If you have a field called 'rare' which is usually false then rare = false sorted by date will be good performance but rare = true sorted by date will be much slower than the if the index were on rare, date.
Btw if you have a date and an in-query on a multi-valued attribute (rather than a simple boolean) this way will be much faster if you are doing a limit on your query.
Agree doc should be clearer here.
Back to your overall problem it depends on thr data volumes and distributions whether you want both indexes (one on date alone and one on flag,date). I'd test and see with your data how much faster it is. If you aren't returning massive data sets or searching on highly selective flags, it may not be worth it to have both.
-- Max
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/c5I4fTbNrOoJ.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
Surprises me too. Maybe someone smarter than me will know :)
-- Max
Oh wait a sec - did you have a bunch of docs sharing dates in the index? It might eg skip a whole bucket of bf: true thay share a common df.
-- Max