Skip to content
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

[BUG] A page request with sorting is adding the sort to the count query #25068

Closed
svankamamidi1 opened this issue Oct 27, 2021 · 3 comments
Closed
Assignees
Labels
azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@svankamamidi1
Copy link

Describe the bug
A page request with sorting is adding the sort to the count query which is creating a lot of performance issues for large data.

Exception or Stack Trace
The count query takes exceptionally high RUs

To Reproduce
Steps to reproduce the behavior:
Create a page request with sorting.
Execure a find with paged results.

Code Snippet
CosmosPageRequest pageable = CosmosPageRequest.of((long) pageInfo.getPageNumber() * maxResults,
pageInfo.getPageNumber(), maxResults.intValue(), pageInfo.getContinuationToken(),
Sort.by(Direction.fromString(sortDirection), sortColumn));
Page currentPageResults = recipientMessageRepository.findByRecipientId(recipientId, pageable)

is generating these queries:
SELECT * FROM ROOT r WHERE r.recipientId = @recipientId0 ORDER BY r.sendDate DESC

SELECT VALUE COUNT(1) FROM r WHERE r.recipientId = @recipientId0 ORDER BY r.sendDate DESC

Expected behavior
Sorting shouldn't be applied to the count query.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Windows 10
  • IDE: Eclipse
  • Library/Libraries: [e.g. com.azure:azure-cosmos-spring-data:3.13.0
  • Java version: 8
  • App Server/Environment: Tomcat
  • Frameworks: Spring Boot

Additional context
We are using page results instead of slice due to an existing issue in azure-cosmos-spring-data library. (#24956)

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 27, 2021
@kushagraThapar
Copy link
Member

@svankamamidi1 - looking at it.

@svankamamidi1
Copy link
Author

Please let us know the update on the hotfix release?

@joshfree joshfree added azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. Cosmos labels Oct 29, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 29, 2021
@trande4884
Copy link
Member

This issue was resolved in the following PR: #29841

@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
azure-spring-cosmos Spring cosmos related issues. Client This issue points to a problem in the data-plane of the library. Cosmos customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants