spring-projects / spring-projects/spring-data-rest
Feature Request: Option to Disable Total Count in Spring Data REST for Improved Performance (or use Slice interface)
@odrotbohm is already working on this.
Since Nov 4, 2024.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
I’d like to request a new feature that allows disabling the total count (count) in Spring Data REST endpoints. In some scenarios, especially with large datasets, counting all entities for pagination can lead to significant performance issues. Therefore, I believe it would be beneficial to have a configurable option to bypass the count query when it’s not essential for the client application.
Suggested Feature
Add a configuration option in Spring Data REST to:
Disable the total count in all paginated responses or use the Slice interface instead of Page for default find.
Optionally control the count per query/request: Allow overriding the count calculation on a per-request basis by setting a query parameter or using an annotation on repository methods.
Use Case
In cases where only the data of the current page is necessary (without the need for total elements) or with many data in bdd, the count query adds overhead. Disabling it could significantly improve response times for paginated endpoints working with large datasets.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.