Hello,
I was tempted to post this to the "Performance-Challenge", but the problem is so general that I think I must be missing something.
I've been testing Hibernate using the TPC-W benchmark (
http://www.tpc.org), specifically, against the JDBC-Servlets implementation on jmob (
http://jmob.objectweb.org/tpcw.html).
I'm using hibernate 2.0.3 and mySQL 4.0.15 here, with the Connector/J driver (it could be that the problem is specific to this driver, but even so, the most common opensource O/R mapper should work with the most common driver for the most common opensource DB, shouldn't it?)
Using JProbe to analyse the performance, I see that about 30%
of the time is spent in ResultSet.findColumn(String), which is called from ResultSet.get*(String). The problem is, getting a named column from a ResultSet is much more expensive than getting a numbered column. That is, ResultSet.getString("title") is slower than ResultSet.getString(1). Worse, since this extra work is associated only with a particular result set, the same overhead is incurred everytime an object is loaded. When we load a bunch of objects using JDBC that give the number of the column, we will always be faster than hibernate, since hibernate uses the name of the returned field.
With this information, it's pretty easy to generate an example where
jdbc outperforms hibernate. If needed, I can send the code I am using. I'm not sure I can post it, as I'm not the holder of the copyright (everything is GPL'd).
Am I missing something here, or is this a performance problem with Hibernate?
Best Regards,
Ron