Azure-docs: Advice on shard key index

Created on 15 Jun 2020  Â·  2Comments  Â·  Source: MicrosoftDocs/azure-docs

Mongo docs state that shard keys must be indexed, but this page on indexing doesn't mention them.
Is it safe to assume that shard keys are/behave as indexed fields?
Is there any benefit or drawback to indexing shard keys?

I think this page is an appropriate place for info on the relation of shards and indexes.
If this is mentioned on some sharding page a link in the relevant docs section would suffice.

Thanks


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 cosmos-dsvc cosmosdb-mongsubsvc cxp product-question triaged

Most helpful comment

Hi @kitsu, great question! In Azure Cosmos DB's API for MongoDB, sharding and indexing are separate concepts. There's no requirement to index your shard key in Azure Cosmos DB's API for MongoDB. However, as with any other property in your document, if this property is a common filter in your queries, we strongly recommend indexing the shard key. For more information about the relationship between partitioning and indexing, this doc is helpful: https://docs.microsoft.com/azure/cosmos-db/how-to-query-container. I can add it to the "Next Steps" section of this doc

All 2 comments

Hi @kitsu, great question! In Azure Cosmos DB's API for MongoDB, sharding and indexing are separate concepts. There's no requirement to index your shard key in Azure Cosmos DB's API for MongoDB. However, as with any other property in your document, if this property is a common filter in your queries, we strongly recommend indexing the shard key. For more information about the relationship between partitioning and indexing, this doc is helpful: https://docs.microsoft.com/azure/cosmos-db/how-to-query-container. I can add it to the "Next Steps" section of this doc

@kitsu I made a doc update in the above PR per Tim's comments. We will now close this issue.

please-close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrdfuse picture mrdfuse  Â·  3Comments

Agazoth picture Agazoth  Â·  3Comments

Ponant picture Ponant  Â·  3Comments

bityob picture bityob  Â·  3Comments

jebeld17 picture jebeld17  Â·  3Comments