How to query by datetime in Doctrine MongoDB ODM?

How does MongoDB shard data? And when query comes, how does it find which shard to go after?

  • I understand how HBase does partitioning (basically range partition on row key. And row key is sorted). I see MongoDB also does range partitioning, but key is not sorted. Then how does it work? Can anyone help to understand internals?

  • Answer:

    > How does MongoDB shard data? This is potentially a very complicated question as sharding has lots of details and edge cases. The basic premise is that MongoDB shards based on a user-selected shard key: http://www.mongodb.org/display/DOCS/Choosing+a+Shard+Key So you shard based on a key you feel will provide even distribution. MongoDB stores ranges of the shard key inside of special set of databases known as the Config DBs The Config DB manages the ranges of data for which each shard is responsible. So each shard "owns" data for a specific set of ranges. > And when query comes, how does it find which shard to go after? With sharding, each query is sent to a router (mongos) process. The router is connected to the config DBs and knows how to route the query. If the query includes the shard key, then mongos will only query the appropriate shards. If the query does not include the shard key, then mongos will query each shard and pull back results. Obviously, the latter is much less performant. However, you can have secondary indexes with MongoDB sharding. So a query without the shard key can still be indexed.

Gaëtan Voyer-Perrault at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.