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
Performance question (ReflectionUtils.getDeclaredMethodOrNull) #363
Comments
In your case, the problem comes from flushing, that's triggered by any SQL query execution. If instead of an array, you use a Pojo that stores the array but implements equals and hashCode, those reflection calls could be prevented. |
Closed as no further details were provided. |
You could avoid those problems like this:
Try using a Pojo to represent your JSON objects. |
Hi, I forgot to reply back then... I'm not sure if that's something one would put into such a library, but back then I made the following change which increased the performance quiet well:
Essentially I added a cache so that each method is only looked up once via reflection. I was not sure if concurrency was neccessary here and just didn't bother using a |
Thanks for the tip. I'll investigate it when I have some time. |
I think I solved my performance problems with a mix of Similar to
For context, I don't know why I was getting a
|
@sverhagen Please create a Pull Request with your change proposal and I'll review it. |
Unfortunately, I can't commit to that at this time. As I said, I solved my performance problems in another way. Since you foreshadowed some further investigation in the future, I just wanted to leave some observations. |
@sverhagen Fixed by #494 |
Hey, I'm very glad to have the hibernate types package which helps me a lot accessing JSON(B) data type in my PostgreSQL database via Hibernate.
But currently I'm facing some performance issues when doing mass inserts for which I do some pre checks (looking up entites). That means, I do have arrays of numbers which I store as JSONB columns and as these numbers represent IDs I do check if those are valid IDs.
Actually my checkup code looks just about this:
I'm using NativeQuery as I already tried to optimise performance through this, but actually it did not change anything from previous standard Hibernate query.
In the profiler >50% of the CPU time for the insert operation can be accounted for the checkups that perform code just like in my previous code snippet:
(the screenshot shows only one of multiple occurences in the call stack)
As you can see in the screenshot the 'performance bottleneck' is the calling of the method Class.getDeclaredMethod by ReflectionUtils.getDeclaredMethodOrNull. I'm a bit suprised as to why this is even called for my native sql query where I do only select constant '1' from a table.
That table on the other hand contains JSONB columns that are mapped in entities via the hibernate types package.
So my questions would be:
The text was updated successfully, but these errors were encountered: