-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[FEATURE REQ] spring-data-cosmos paging without incurring cost of count query for custom query using paginationQuery method. #23484
Comments
@backwind1233 @yiliuTo could you please take a look? |
Hi, @kushagraThapar could you please take a look? |
@anath-onetrust - I see that sliceQuery in CosmosTemplate is actually a public API. So that can be used if needed.
|
@kushagraThapar Yes there is a public sliceQuery method in CosmosTemplate but that does not meet our requirement .We need to pass a return argument in sliceQuery which is not supported by public method but private method supports it .Sharing both method signature for reference . private Slice sliceQuery(SqlQuerySpec querySpec, public Slice sliceQuery(CosmosQuery query, Class domainType, String containerName) |
@anath-onetrust - in the public API, |
@kushagraThapar I saw the API but here we have an issue to use existing public API since the API only supports CosmosQuery in query parameter but our requirement is to pass SqlQuerySpec in API call which is not supported .Is there any way to achieve this. public Slice sliceQuery(CosmosQuery query, Class domainType, String containerName) |
@kushagraThapar Could you please update us we are waiting for it . |
@anath-onetrust while we try to implement this in spring / or investigate the possibility of it, can you use cosmos java SDK client and query directly using java SDK instead of spring ? |
@kushagraThapar what if we add a new public method in CosmosTemplate that internally call private sliceQuery method something like . public Slice runSliceQuery(SqlQuerySpec querySpec, Pageable pageable, Class<?> domainType, Class returnType) { I believe this is a straight forward change if you accept this I can raise a PR for same . |
@anath-onetrust - That seems like a possible solution for the time being. We can try it out and see how it works for you guys. Please raise a PR and I will look into it. Thank you! |
…nt query for custom query using paginationQuery method. Azure#23484
@kushagraThapar I have raised a PR please let me know if I have missed anything . |
@anath-onetrust - Thanks for raising the PR, it looks good to me. Please read this github issue, where we are having the discussion on how to support pagination on spring data cosmos SDK - #24262 |
For issue #24262 it is worth pointing out that you can add a custom method to the repository returning Slice<T> and it will automatically return results that support pagination via continuation token without issuing a count query, and without having to call custom methods on the cosmosTemplate. Even if you are planning to adjust the way the main pageable implementation works, it makes sense to include the runSliceQuery api for parity with runPageQuery, and that would be enough to unblock us. |
@johnmannix @anath-onetrust - this has been done and will be released today. Thank you again for your contribution as always :) |
Is your feature request related to a problem? Please describe.
I want to page through a large result set using continuation tokens and the azure-spring-data-cosmos library method which will accept my query with return argument. However, CosmosTemplate repository methods(paginationQuery) always issue a count query to populate the total elements in the page response, and when the query is complex and the result set is large, the count query can be very expensive.
Describe the solution you'd like
I would like to be able to use CosmosPageRequest to fetch a page of data with a continuation token without issuing a count query to populate the total elements. There is a private slice method in CosmosTemplate which is called from paginationQuery method after executing count query , would like a wrapper public method of that so that it can call directly to avoid count query .Existing private method private Slice sliceQuery(SqlQuerySpec querySpec,Pageable pageable, Sort sort,Class returnType, String containerName)
Describe alternatives you've considered
Considered extending CosmosTemplate, but too many fields and methods are defined with private access modifiers.
Additional context
Add any other context or screenshots about the feature request here.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: