Skip to content

Conversation

minwoo1999
Copy link
Contributor

@minwoo1999 minwoo1999 commented Dec 13, 2024

Changes

Updated getResultList().isEmpty() to getResultStream().findFirst().isPresent() for checking query existence.
Improved performance by processing only the first result.

Reason

It seems that this method is only meant to check if the query exists. Therefore, fetching the entire query result does not seem necessary.
Avoids loading all results into memory, reducing overhead and improving efficiency.

Testing

Verified with existing test cases, ensuring identical results.

Review Request

Please review and share any feedback. 🙇‍♂️

by using getResultStream and findFirst
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 13, 2024
@mp911de
Copy link
Member

mp911de commented Dec 16, 2024

ExistsExecution is only used for derived queries where we set query.setMaxResults(1). Therefore, instantiating a Java 8 stream instead of reading one result into a List is almost the same overhead. We want to keep our code as-is.

@mp911de mp911de closed this Dec 16, 2024
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants