The compound index will be bigger and it may be be a hair slower but in real life I doubt you'll notice if the field you are querying is the first field. If it is the second field it won't be used for the most part.
-- Max
--
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.
The compound index will be bigger and it may be be a hair slower but in real life I doubt you'll notice if the field you are querying is the first field. If it is the second field it won't be used for the most part.
-- Max
On Mar 22, 2012 6:03 PM, "Łukasz Kuczera" <l.ku...@jextreme.pl> wrote:
Is there a performance difference for querying one field from compound index than from single key one ?Its not clear in documentation at least not for me.Thanks--
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.
If you have an index on a, b, c and you query on a it will be fast; also fast if you are querying on a, b or a, b, c. Querying on just b or just c won't be fast.
If you are querying the 3 keys individually then a single compound index won't work well.
-- Max
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/iwXVyLis0ggJ.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
If any one of the 3 fields you query on is selective on its own it will be fast. If not it won't.
For example if you are querying on userid, status with an index on each it will probably be fast because the index on userid will likely match only a few records.
That said you can replace the index on a with a, b c (and keep the indexes on b and c).
-- Max
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/pinCE-GbCpUJ.