I have a requirement to query by documents (cosmos DB) based on unique key in batch request.
My approach to above requirement
- Since my key say customerId is unique I am making customerId as Id and Partition key also as /id.
- Since its batch read request (25 calls/per request and 10 batch requests/sec) , I am utilizing “in” operator in SQL query and extracting all the documents by CosmosClient.CreateDocumentQuery function Ex: my SQL query would look like “Select * from c where c.Id in (‘a1’,’b1’)
Following are my feed options:
new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true, MaxDegreeOfParallelism = -1, MaxBufferedItemCount = -1 }
Based on the above scenario:
Am I actually utilizing the query by Id functionality well to achieve faster response time?
Does EnableCrossPartitionQuery makes sense in the current scenario?
Am I doing partioning right?
Is there a better way I can utilize the capability of extracting the data is key value pair fashion?