Sharding a MongoDB instance by a spatial key and a date This may be more an advice than anything else, but I'm designing an app that stores in a table objects that have a 2dsphere index and they also have a date (+time), both of them being part of queries that I'm doing to retrieve some of these objects.

This database will have to be sharded, so sharding according to the spatial key sounds like the first step. It's basically a given that this index will be part of the sharded key. The other key should be time, and I'm pretty sure that hashing the time will not be adequate, as the queries are looking for date interval for the objects. So hashed will make force accessing all chunks (with the proper spatial constraints), which I don't want.

So my question is to know if this is feasible and also if mongodb will be clever enough not to split according to the spatial key unless I manually ask for it?
my question is to know if this is feasible


A shard key index cannot be multi key, text, or geospatial, so part of your theoretical approach is definitely infeasible. You also mention considering hashed sharding on a datetime field, which could provide better data distribution for otherwise monotonically increasing values like a timestamp. However, a tradeoff is that hashed sharding does not support range queries since adjacent source values will now have distributed shard key values.


  also if mongodb will be clever enough not to split according to the spatial key unless I manually ask for it?


Since a shard key cannot be an array or geospatial value this specific question doesn't really apply.

The default behaviour of MongoDB sharding is to allow shard key range splits (aka "chunk splits") to happen automatically so that the sharded cluster balancer will redistribute data between shards based on chunk imbalances. It is possible to adjust the default behaviour (for example, disabling autosplits for a cluster or balancing for a collection), but you should only do this with careful consideration. Micromanaging a sharded cluster can be counter-productive.