Joshua Swoyer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5fa3412...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYzlmYzgzYTE1...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16853?atlOrigin=eyJpIjoiYzlmYz...
) HHH-16853 (
https://hibernate.atlassian.net/browse/HHH-16853?atlOrigin=eyJpIjoiYzlmYz...
) Setting Named Query Parameters Is VERY Slow (
https://hibernate.atlassian.net/browse/HHH-16853?atlOrigin=eyJpIjoiYzlmYz...
)
Issue Type: Bug Affects Versions: 6.1.6 Assignee: Unassigned Components: hibernate-core
Created: 26/Jun/2023 13:56 PM Priority: Major Reporter: Joshua Swoyer (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5fa3412...
)
As a little bit of background, we are attempting to do bulk upsert statements for
performance in an application. This lead to us generating our own sql from a list of
models (1000 records at a time).
We were using hibenrate’s native query generator. Since we were generating the sql, we
initially implimented parameters positionally, before realizing these are no longer
supported. Upong releasing the code and attempting to ingest data we eventually noticed
that preparing a query was taking 10x as long as running the query did. Turning on
profiling I was able to find that this is the issue:
https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/m...
@Override
public QueryParameterImplementor<?> findQueryParameter(String name) {
for ( QueryParameterImplementor<?> queryParameter : queryParameters.keySet() ) {
if ( name.equals( queryParameter.getName() ) )
{ return queryParameter; }
}
return null;
}
The above code is very slow when there are many query parameters. As best I can tell the
queryParameters are immutable in this class, only created in the constructor, and new
parameters are never added. It looks like it would be very easy to create two maps on
initialization that has the name as the key. Though there may be things going on here that
I’m not entirely following.
Assuming this is all that is necessary I’d be happy to submit a PR if that is helpful.
(
https://hibernate.atlassian.net/browse/HHH-16853#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16853#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:3bc807d )