Hi VD •,
Welcome to Microsoft Q&A forum.
As I understand, you want to know Cosmos DB NoSQL LIMIT OFFSET performance in .NET SDK and Azure Portal.
- The RU charge of a query with
OFFSET LIMIT
increases as the number of terms being offset increases. For queries that have multiple pages of results, we typically recommend using continuation tokens. Continuation tokens are a "bookmark" for the place where the query can later resume. If you useOFFSET LIMIT
, there's no "bookmark." If you wanted to return the query's next page, you would have to start from the beginning. - You should use
OFFSET LIMIT
for cases when you would like to skip items entirely and save client resources. For example, you should useOFFSET LIMIT
if you want to skip to the 1000th query result and have no need to view results 1 through 999. On the backend,OFFSET LIMIT
still loads each item, including those items that are skipped. The performance advantage is measured in reducing client resources by avoiding processing items that aren't needed.
In the .NET SDK and Java SDK, you can optionally use continuation tokens as a bookmark for your query's progress. Azure Cosmos DB for NoSQL query executions are stateless at the server side and can be resumed at any time using the continuation token. For the Python SDK, continuation tokens are only supported for single partition queries. The partition key must be specified in the options object because it's not sufficient to have it in the query itself.
Here are some example for using continuation tokens:
If the query returns a continuation token, then there are extra query results.
In Azure Cosmos DB for NoSQL's REST API, you can manage continuation tokens with the x-ms-continuation
header. As with querying with the .NET or Java SDK, if the x-ms-continuation
response header isn't empty, it means the query has extra results.
As long as you're using the same SDK version, continuation tokens never expire. You can optionally restrict the size of a continuation token. Regardless of the amount of data or number of physical partitions in your container, queries return a single continuation token.
Refer Tips & Tricks for Query Pagination in Azure Cosmos DB for more insight into query performance.
Also, take a look at Stackoverflow thread for reference: https://stackoverflow.com/questions/68643111/cosmos-db-net-sdk-v3-query-with-paging-example-needed
More on query performance tips for Azure Cosmos DB SDKs:
Let me know if this helps or you have more queries.
Thanks.