Reputation: 3250
I have enabled my statistics for hibernate using - spring.jpa.properties.hibernate.generate_statistics=true
. Now in the debug console I can see the message like below:
29721 nanoseconds spent acquiring 1 JDBC connections;
34228 nanoseconds spent releasing 1 JDBC connections;
1465946 nanoseconds spent preparing 17 JDBC statements;
92174245 nanoseconds spent executing 17 JDBC statements;
I am trying to fine tune the entire time consumed.
Question: What are my options or what can be done to reduce/eliminate this time wasted every time on the same set of queries - 1465946 nanoseconds spent preparing
?
Upvotes: 0
Views: 1445
Reputation: 16400
You can't really do anything here except for trying to reduce the amount of JDBC statements. This could be done by doing second level caching or using fetch joins or entity graphs to eagerly load some data through joins rather than through dedicated select statements. Without knowing exactly what your application is doing, this is impossible though. Anyway, 1.4 milliseconds is not that much compared to the 92 milliseconds it takes to execute all these statements. IMO you should rather try to reduce the execution time by introducing proper indexes or whatever is appropriate for your queries to improve performance.
Upvotes: 1
Reputation: 2197
If you're using Hibernate you can also reduce processing time with @Cache
annotation
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
Upvotes: 1