Hibernate configuration to analyse query

Last day I was working on an application to increase its performance. I found 3 configurations that helped me to analyse query and get rid of unwanted queries.

hibernate.show_sql: true | false

hibernate.format_sql: true | false

Above two parameter can be configured to to display the hibernate queries. To my utter surprise even a simple application makes so many queries.

hibernate.generate_statistics : true|false this displays the hibernate statistics

Session Metrics {
0 nanoseconds spent acquiring 0 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
0 nanoseconds spent preparing 0 JDBC statements;
0 nanoseconds spent executing 0 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)

This gives the details about all the activity in executing a query.

Both of these information can be used to tweak query and configuration to optimize hibernate performance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s