Noah Stahl
Noah Stahl

Reputation: 7623

Indexing synthetic partition key

I have a Cosmos container using a synthetic partition key /pk, where the value is only used for partitioning and never used in a query clause. Is there any reason not to exclude this path from indexing, given that the value is provided as the partition key with all operations? It seems like it should be excluded from indexing by definition, but not sure if partitioning and indexing somehow interact.

Upvotes: 0

Views: 295

Answers (1)

Mark Brown
Mark Brown

Reputation: 8793

You should always include the partition key in your queries because queries without the partition key in the where clause will be fan outs which you really should try to avoid.

It is also recommended to keep the partition key in the index. There are quite a few people confused by this. We are soon going to start indexing it automatically, even if you exclude it so people don't suffer from not indexing it.

Upvotes: 1

Related Questions