question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IDocumentClient - Read a partition?

See original GitHub issue

Is it possible to read all documents in a partition in a single round trip?

I have tried CreateDocumentQuery, but that still seems to result in two server trips, which is less than ideal.

            var files = _documentClient.CreateDocumentQuery<TDataType>(_documentCollectionUri, new FeedOptions
            {
                PartitionKey = new PartitionKey(partitionKey.ToString()),
                MaxItemCount = 100
            }).ToList();

Note that the trips below are from a query which only has 2/3 records, paging should have had no effect.

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
a-visharcommented, Jun 5, 2020

Thank you so much for taking the time to walk me through this. I have implemented the changes we discussed and it has improved first load for users by 95%!

1reaction
ealsurcommented, Jun 5, 2020

You can avoid it warming up the caches. The first request on a Client requires the addresses to be resolved for the container you want to interact with, this happens with V2 or V3 SDK, there is no way to get those addresses without doing a request. That request happens on your first ever request to the container, not the rest.

If you do a Read for an item that does not exist on initialization (this could be when the Function App is starting or when you are creating the Singleton client), that would do the required address resolution and not impact the actual list you are doing later.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Repository that support query by partition key without ...
I am developing an application that using IDocumentClient to perform query to CosmosDB. My GenericRepository support for query by Id and ...
Read more >
IDocumentClient.ExecuteStoredProcedureAsync Method
Executes a stored procedure against a partitioned collection in the Azure Cosmos DB service as an asynchronous operation, specifiying a target partition.
Read more >
Exploring the new .NET Cosmos DB SDK (v3)
Okay so we created an entity, how can we read it back? CosmosItemResponse<TestEntity> res = await container.Items.ReadItemAsync<TestEntity>( ...
Read more >
Partitioning strategies for Cosmos Database SQL API - Part 1
In the first part of this series, the engineering team shares their partitioning strategies for Cosmos Database SQL API. Read the blog now....
Read more >
Cosmos DB read a single document without partition key
Posting as answer. Yes you have to do a fan out query but id is only distinct per partition key so even then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found