Friday I had a performance problem at work. We were using hibernate to do all the DAO for us, so no Select statements. We optimized a view for faster retrieval of the data, but it still took the application a long time to retrieve a large resultset, a small resultset went fast. Okay let’s do a small testsetup to very this issue, in the small testcase (1 mapping onto the same view) it was fast. Hmm bizar, okay let’s try it back in the application. Again slow, hmmm very odd!?
Okay what now, go to #hibernate on freenode and ask their. They told me to check with a profiler. So I did, hmm even more bizar. There wasn’t any extra cpu performance or memory usage. Wait, what’s this. The normal jdbc drops his cpu for a very short time (waiting for the database response) while the problem use case waits 10 seconds longer. Hmmm, okay how do we solve this. Well if you download Hibernate you get the source for free.
Okay put the source into our project and start debugging. After some time, I came to the conclusion that in our application the PreparedStatement.executeQuery() that just returns the Oracle cursor takes +10 seconds while in the testcase it only takes 1 second or less. So if we enable all the hibernate mappings something in the Oracle jdbc driver goes insane. Well for now I retrieved the java Connection object and perform the query myself. But I sure hope the guys over at hibernate or oracle can tell me what the problem is. Just imagine I had to debug this in a closed source environment, I’ld prolly still be waiting for them to create a use case like ours.