Hibernate 7 - the performance issue related to the large filter conditions

We are in the migration process from Hibernate 6 to Hibernate 7.
And we encountered a performance issue with large filter conditions.
In our application, there are filter conditions > 2000 characters (including whitespaces)
We add these filters based on our custom annotation at runtime.
Application startup time increased from 15 seconds to 300 seconds.
After debugging the Hibernate code, we have found that the issue is in the method:
org.hibernate.sql.Template#renderWhereStringTemplate

That method runs on the initialization of EntityPersisters from org.hibernate.persister.entity.AbstractEntityPersister#AbstractEntityPersister

The performance issue is in the method
org.hibernate.sql.Template#isFunctionCall
That code was changed in the 7th version.

Any thoughts/suggestion how we can solve this or avoid this behavior?

First, you would need to provide us a reproducer and/or show us flame graphs of the behavior so that we can understand what is wrong.
If you have a clue about what doesn’t perform, you’re very welcome to open a PR and explain how your changes benefit performance.

I have found that you created a fix for that issue:

But you targeted 7.4.x release.
Can I ask about the reason why you don’t plan to release it in 7.2.x?
It was marked as high priority …

Thanks

We don’t backport improvements. Since the generated SQL is cached, it would only be a slowdown the first time a SQL string is generated, so I wouldn’t say that this is very critical. Also, the priority “Major” is the default, so that doesn’t have any meaning.
If you are an IBM or Red Hat customer and you can give details that this really slows down your app significantly, you could create a support ticket for which we could look into a one off patch or maybe reconsider this to be a “performance bug”. But unless someone does that, we follow our policy of not backporting improvments.

Thanks for your answer.

For us, this issue is critical because it drastically affects application startup, now it is 20 times slower.

Can we ask you to share a patch?

Sorry, but I can’t help just you. The Hibernate Team is small and we have clear rules. Like I already wrote, we will not reclassify such issues unless we see a real need or are asked to by paying customers.
I’m sorry it’s slower for you, but you will have to patch it yourself then. Hibernate ORM is open source after all. Nothing prevents you from forking the repository, applying the patch and releasing an artifact to your own artifact repository.

Thanks for your clarifications!

I have found that PR in your repo, it works on our side!