Sumit Talesara
Sumit Talesara

Reputation: 143

Fastest way to fetch multiple documents from Azure Cosmos DB

I have a SQL API Cosmos DB collection with the id and partition key both equal to /id.

Given a list of IDs, I need to fetch all those documents. When using the .NET SDK (v3.25), which of the below Container class methods is recommended to get the lowest latency:

  1. In parallel, use ReadItemAsync to read all documents.
  2. Use ReadManyItemsAsync to read all the documents.
  3. Use GetItemQueryIterator with a SQL query of the form SELECT * FROM c where c.id in ('id-1', 'id-2', ...).

Upvotes: 2

Views: 1597

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222722

If you want to retrieve large group of individual items, the most efficient way is to use ReadManyItemsAsync() rather than invoking ReadItemAsync() many times/Parallel.

Upvotes: 5

Related Questions