-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new method to support pagination #57
Conversation
This is awesome, thank you so much @zhangzunke - I'll do a full review this weekend. Thanks again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a few initial observations. I do really like what you have thus far -- would you be able to add some tests, or a sample app usage? See the samples and test directories.
Microsoft.Azure.CosmosRepository/src/Dtos/IPagedResultRequest.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.CosmosRepository/src/Dtos/IPagedResultRequest.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.CosmosRepository/src/Dtos/ILimitedResultRequest.cs
Outdated
Show resolved
Hide resolved
That makes sense. Co-authored-by: David Pine <david.pine@microsoft.com>
Good catch. Co-authored-by: David Pine <david.pine@microsoft.com>
Make sense. Co-authored-by: David Pine <david.pine@microsoft.com>
Good catch Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
…t.cs Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Hi @IEvangelist, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi again @zhangzunke - thanks for all these updates, I have a few more things I'm curious about.
Also, from the design perspective - as a consumer of this API how would I know if there are more pages, and is there a way to also communicate the total number of pages? If I query for a max of 10 items, and get back 10 items, how would I know if there are more items than the 10 I received for the first page?
Hi @IEvangelist, good catch, the method GetListAsync will return a PagedResult, it has a property TotalCount which is all of the items count when you query, so a consumer can use the property to calculate the total number of pages, the property is not the current page items count. |
@zhangzunke Another thought is that the |
Hi @IEvangelist, the first design is that the method only provides a basic pagination feature, the pagination method only accept Regarding how to get the next page, because the consumer knows the grid current page, page size and the total count of the data (it comes from |
@zhangzunke Could you show me an example of it being used, so that I can wrap my head around the expected usage? Do you have an example, where you there are 1,037 records that match the query -- and you page them with a max of 50 per page... what would that look like? |
Hi @IEvangelist, I showed a simple example as below, in our project these codes should be implemented by typescript on the SPA, so I just showed the basic cases when we used pagination, is that expected usage for you?
|
Microsoft.Azure.CosmosRepository/src/Pagination/IPagedResultRequest.cs
Outdated
Show resolved
Hide resolved
Cosmos DB team suggest using continuation tokens instead of the Skip/Take approach to pagination, so I closed the PR.
|
Quoting @AndriySvyryd here, the EF Cosmos provider automatically uses continuation tokens under the hood when normal query results are enumerated. In other words, for optimal pagination, simply execute your query and stream the results (e.g. with foreach); the provider will fetch results incrementally. Avoid buffering the entire results e.g. with ToList. dotnet/efcore#24513 tracks allowing the user to set the number of items fetched each time. Using Skip may still be useful if one doesn't want to traverse the first N items; but executing the same query with different Skip/Take windows would result in bad perf and increased costs. (@AndriySvyryd will correct if I wrote anything wrong) |
@all-contributors please add @zhangzunke for ideas and code |
I've put up a pull request to add @zhangzunke! 🎉 |
@all-contributors please add @roji for research |
I couldn't determine any contributions to add, did you specify any contributions? |
@all-contributors please add @roji for research |
I couldn't determine any contributions to add, did you specify any contributions? |
@all-contributors please add @roji for review |
I've put up a pull request to add @roji! 🎉 |
Hi I have been trying to wrap my head around the refresh tokens would this comment on the open issue sound about right, continuation tokens are great for a load more ... scenario but for someone who wants to skip directly to page 6 for example they would not have any real benefit? Thanks in advance :) |
@mumby0168 if my mental model is correct (not an expert), you can still use Skip to skip directly to page 6, and from that point, stream everything else (using continuation tokens). IIRC doing so wouldn't reduce Cosmos processing costs for the 5 skipped pages, but would save you from having to transfer that data over the network. |
Got it, put the basis of my plan together in this draft PR #82 , for the implementation if you could spare some time to have a look it would be greatly appreciated 👍 |
Sir, I added a method to support pagination, please review it. thanks.
Fixes #53