Skip to content

Commit 9c99b54

Browse files
authored
Merge pull request #78730 from SnehaGunda/minthroughput
Updating maxItemCount details & note for pagination limit per feedback in Git issue
2 parents 7df70e8 + 4736c0c commit 9c99b54

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

articles/cosmos-db/performance-tips.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,21 @@ So if you're asking "How can I improve my database performance?" consider the fo
135135
<a id="tune-page-size"></a>
136136
1. **Tune the page size for queries/read feeds for better performance**
137137

138-
When performing a bulk read of documents using read feed functionality (for example, ReadDocumentFeedAsync) or when issuing a SQL query, the results are returned in a segmented fashion if the result set is too large. By default, results are returned in chunks of 100 items or 1 MB, whichever limit is hit first.
138+
When performing a bulk read of documents using read feed functionality (for example, ReadDocumentFeedAsync) or when issuing a SQL query, the results are returned in a segmented fashion if the result set is too large. By default, results are returned in chunks of 100 items or 1 MB, whichever limit is hit first.
139139

140-
To reduce the number of network round trips required to retrieve all applicable results, you can increase the page size using [x-ms-max-item-count](https://docs.microsoft.com/rest/api/cosmos-db/common-cosmosdb-rest-request-headers) request header to up to 1000. In cases where you need to display only a few results, for example, if your user interface or application API returns only 10 results a time, you can also decrease the page size to 10 to reduce the throughput consumed for reads and queries.
140+
To reduce the number of network round trips required to retrieve all applicable results, you can increase the page size using [x-ms-max-item-count](https://docs.microsoft.com/rest/api/cosmos-db/common-cosmosdb-rest-request-headers) request header to up to 1000. In cases where you need to display only a few results, for example, if your user interface or application API returns only 10 results a time, you can also decrease the page size to 10 to reduce the throughput consumed for reads and queries.
141141
142-
You may also set the page size using the available Azure Cosmos DB SDKs. For example:
142+
> [!NOTE]
143+
> The maxItemCount property shouldn't be used just for pagination purpose. It's main usage it to improve the performance of queries by reducing the maximum number of items returned in a single page.
144+
145+
You can also set the page size using the available Azure Cosmos DB SDKs. The [MaxItemCount](/dotnet/api/microsoft.azure.documents.client.feedoptions.maxitemcount?view=azure-dotnet) property in FeedOptions allows you to set the maximum number of items to be returned in the enmuration operation. When `maxItemCount` is set to -1, the SDK automatically finds the most optimal value depending on the document size. For example:
146+
147+
```csharp
148+
IQueryable<dynamic> authorResults = client.CreateDocumentQuery(documentCollection.SelfLink, "SELECT p.Author FROM Pages p WHERE p.Title = 'About Seattle'", new FeedOptions { MaxItemCount = 1000 });
149+
```
150+
151+
When a query is executed, the resulting data is sent within a TCP packet. If you specify too low value for `maxItemCount`, the number of trips required to send the data within the TCP packet are high, which impacts the performance. So if you are not sure what value to set for `maxItemCount` property, it's best to set it to -1 and let the SDK choose the default value.
143152

144-
IQueryable<dynamic> authorResults = client.CreateDocumentQuery(documentCollection.SelfLink, "SELECT p.Author FROM Pages p WHERE p.Title = 'About Seattle'", new FeedOptions { MaxItemCount = 1000 });
145153
10. **Increase number of threads/tasks**
146154

147155
See [Increase number of threads/tasks](#increase-threads) in the Networking section.

0 commit comments

Comments
 (0)