Not a bug but a query on why my code is slow
See original GitHub issueA query loading all documents from a single partition on a container is very slow. 1481 documents, all of the same type. 6 MB of data takes between 1.5 seconds on my laptop with 200Mbps internet. Would I expect this query to be so slow?
This is a cut down version of the code:
var requestOptions = new QueryRequestOptions()
{
MaxBufferedItemCount = -1,
MaxItemCount = -1,
PartitionKey = new PartitionKey(partitionKey.ToString()),
};
var setIterator = container
.GetItemLinqQueryable<T>(false, requestOptions: requestOptions).ToFeedIterator();
var list = new List<T>();
while (setIterator.HasMoreResults)
{
var response = await setIterator.ReadNextAsync().ConfigureAwait(false);
list.AddRange(response);
}
// takes 2 to 4 seconds to get here
The execution time is all spent running the ReadNextAsync
function.
Here are query stats from the COSMOS page on Azure:
Thank you.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
5 reasons why your code is running so slowly—and how to ...
Here's how to address why the code runs well on your development machine but has totally borked in production.
Read more >sql server - Why would a query in code be slower than a ...
We are currently facing an issue where the same query executed in the code takes (on average) 15-20 seconds. The same query on...
Read more >Query extremely slow in code but fast in SSMS
Both tables are well indexed and the execution plan in SSMS says they are using index seeks for the look-ups so they are...
Read more >Troubleshoot slow-running queries - SQL Server
RUNNING: Queries can be slow because they're running (executing) for a long time. In other words, these queries are actively using CPU resources...
Read more >Bug found. Causes whole website to slow down significantly
My client uses it a lot and they have a lot of IP addresses in it. However, recently we found that the website...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Will do and thank you
Reference: https://learn.microsoft.com/en-us/azure/cosmos-db/sql/troubleshoot-dot-net-sdk-slow-request?tabs=cpu-new#capture-diagnostics