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

Feature "Rewrite queries using LIKE with wildcards using CONCAT" kills performance on Postgres #3189

Closed
Sukramolas opened this issue Oct 9, 2023 · 3 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@Sukramolas
Copy link

This change introduced in Spring JPA 2.7.13 changes LIKE queries to CONCAT($1, '%') format. However Postgres cannot use table indexes when right-hand side clause has a function (like CONCAT), so invoking query containing CONCAT will perform very poorly on large tables.

As suggested fix this optimization should be optional (e.g. via Spring JPA property setting), and can default to be active. But it should be possible to return to 2.7.12 version of LIKE query.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 9, 2023
@mp911de
Copy link
Member

mp911de commented Oct 23, 2023

See also #2939 and #2760

@mp911de mp911de added the for: team-attention An issue we need to discuss as a team to make progress label Oct 23, 2023
@Sukramolas
Copy link
Author

To add to my original comment, looking at index behavior with LIKE 'ABC%' vs LIKE ( CONCAT ( 'ABC', '%' ) )

The LIKE % results into Index Scan, whereas CONCAT results into SEQ_SCAN which has much worse performance over large tables (> 100M rows).

@mp911de mp911de removed status: waiting-for-triage An issue we've not yet triaged for: team-attention An issue we need to discuss as a team to make progress labels Dec 14, 2023
@mp911de mp911de added the status: invalid An issue that we don't feel is valid label Dec 14, 2023
@mp911de
Copy link
Member

mp911de commented Dec 14, 2023

Closing this issue as the 2.7 development line is no longer maintained. The 3.x development line no longer uses CONCAT for like queries.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants