-
-
Notifications
You must be signed in to change notification settings - Fork 44
Pagination with MAX_ITEM_COUNT -1 #115
Comments
This best practice must be new. It definately wasn't the recommendation before. I've personally seen scenarios where setting this to -1 can cause some serious performance issues.. I am willing to change that but if you change the pageSize to -1 but I will also need to benchmark the behavior. Can you give me a hand by branching Cosmonaut and testing it with the -1 pageSize? |
I've done some tests. It's difficult to say and surely depends upon scenario:
The advantage of using fixed bucket size is of course the spread in RU consumption. An advantage of using the second approach, is the network call time adds up when a user would request many records in a listpage. But in our case it would take more than 300 items before it gets interesting to collect more data at once. PS; those are local development timings ;) |
Thanks for this @Mortana89.
This is the reason why I disabled that in the first place. I could remove the -1 limitation to allow for this usecase but I am not sure if that's the right approach to this. I will put this on hold until I settle on the approach. |
Currently Cosmonaut does not allow fetching data with pagination without defining an initial page size (as first request). This is against a recommendation we received from Cosmos DB:
You are using the query page size of 100 for queries for your Azure Cosmos DB container. We recommend using a page size of -1 for faster scans
Upon following the following article: https://docs.microsoft.com/nl-nl/azure/cosmos-db/sql-api-query-metrics#max-item-count
It's clear that it's better to specify -1 as our max_item_count for the first fetch, so Cosmos DB can determine what's the max response set. Further down the road we can then use continuation token and follow normal path.
However, the SDK currently does not support specifying -1 due to the following lines:
Cosmonaut/src/Cosmonaut/Extensions/PaginationExtensions.cs
Line 26 in 2619335
Cosmonaut/src/Cosmonaut/Extensions/PaginationExtensions.cs
Line 45 in 2619335
Can these be changed to also support -1 as page size, as such cosmos DB can determine the max size?
The text was updated successfully, but these errors were encountered: