Pregunta

In Mongo docs, it says that

MongoDB automatically computes the hashes when resolving queries using hashed indexes. Applications do not need to compute hashes.

From here: http://docs.mongodb.org/manual/tutorial/choose-a-shard-key/

My common sense tells me that this can only be valid for EQUALS queries. Is this also valid for range queries? As hashing does not maintain order, I suppose not.

Example: Say I have a hashed shard key on field k. Definitely, it can help isolate a query like {k : 111}. Can it also help isolate a query like {k : {'$gt' : 111}} ?

Thanks in advance.

¿Fue útil?

Solución

From the 3rd paragraph here: http://docs.mongodb.org/manual/core/index-hashed/

Hashed indexes do not support range queries.

Sorry - it can be frustrating, for sure.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top