Compound index suggestion for sharded collection

There is a collection with a sharding key on the hashed index file_id . In addition, commonly used queries in the business require both file_id and version as query conditions. Given that I already have the sharding key, do I still need to create a compound index (file_id, version) ? Or is it sufficient to create an index on (version) only?

No, if your shard key on file id is selective enough. (e.g. unique). Yes otherwise.

No. this won’t work. Check manual page for indexes for more info.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.