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

Missing support for VALUES list in SELECT statements #1300

Closed
roookeee opened this issue Aug 1, 2022 · 4 comments
Closed

Missing support for VALUES list in SELECT statements #1300

roookeee opened this issue Aug 1, 2022 · 4 comments
Assignees
Labels
for: external-project For an external project and not something we can fix

Comments

@roookeee
Copy link

roookeee commented Aug 1, 2022

Currently spring-data-jdbc does not support SELECT statements that use the VALUES keyword:

interface MyRepository {
    @Query("SELECT * FROM my_entity WHERE id IN (VALUES (:ids))")
    List<MyEntity> myQuery(List<String> ids)
}

:ids is not properly expanded (it needs to put every list entry into ()) and thus generates wrong SQL.
I know this would be complex to support for complex objects types as IN-statements works with tuples in some databases but the simple, one-valued variant should be pretty straightforward.

At least PostgreSQL generates different plans for a simple IN vs IN VALUES clause, especially when the input list is big (>100) which perform quite differently (10-30% worse for us).
Using a VALUES list is also interesting when using CTE (WITH) to populate a temporary table with user provided input, this is not achievable with an IN statement.

Disclaimer: I haven't checked if VALUES expansion works in custom INSERTS

@roookeee roookeee changed the title Support VALUES list in SELECT statements Missing support for VALUES list in SELECT statements Aug 1, 2022
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 1, 2022
@schauder
Copy link
Contributor

schauder commented Aug 1, 2022

This should get implemented in JdbcTemplate, which already does the same thing for IN.

Please create a new issue over https://github.com/spring-projects/spring-framework/issues and leave a link to it here.

Thanks.

@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Aug 8, 2022
@roookeee
Copy link
Author

roookeee commented Aug 8, 2022

I created an issue in spring framework.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Aug 8, 2022
@schauder
Copy link
Contributor

schauder commented Aug 9, 2022

Thanks

@schauder schauder closed this as completed Aug 9, 2022
@schauder schauder added for: external-project For an external project and not something we can fix and removed status: feedback-provided Feedback has been provided labels Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix
Projects
None yet
Development

No branches or pull requests

3 participants