aspose file tools*
The moose likes Object Relational Mapping and the fly likes Perforarmance diff bet hibernate and JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Perforarmance diff bet hibernate and JDBC" Watch "Perforarmance diff bet hibernate and JDBC" New topic
Author

Perforarmance diff bet hibernate and JDBC

Prasanna Sankar
Greenhorn

Joined: Apr 28, 2009
Posts: 3
Hi all,

I am kind of new to hibernate. For last few days i am observing time taken to execute the hibernate query is little on the higher side.

The time taken here is only w.r.t executing the SQL query that is translated from the hibernate query.

When i take the equivalent SQL query from the logs and execute it on the oracle prompt it takes 4 ms, but i hibernate take 16 secs for the same query.

I do agree there ll be difference in performance compared this way, but performance here is like chalk and cheese.


The single SQL query formed here is something like this

select * from (select column1, column2, column3....., column 29 from A LEFT JOIN B on a.id=b.id LEFT JOIN C on a.id=c.id where <some criteria> order by column1) where rownum < 1001 ;

A contains 2.9 million rows
B contains 3 rows
C contains 4 million rows

All the id columns have indexed enabled.

The same query executed through JDBC takes only 2 secs.

Am i missing something here

Thanks in advance.
Nidhi Singhal
Ranch Hand

Joined: Sep 19, 2004
Posts: 89

With hibernate, you can do batch updates - it reduces the database roundtrips.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Set the SHOW_SQL setting in the Hibernate configuration file to true and take a look at exactly what SQL is being generated by Hibernate. That might prove interesting.

-Cameron McKenzie
Prasanna Sankar
Greenhorn

Joined: Apr 28, 2009
Posts: 3
Cameron Wallace McKenzie wrote:Set the SHOW_SQL setting in the Hibernate configuration file to true and take a look at exactly what SQL is being generated by Hibernate. That might prove interesting.

-Cameron McKenzie


I did that the SQL query listed in the post is from logs, the trouble the eact same query takes very less time to execute from prompt compared to hibernate and i have no clue as to why.
Prasanna Sankar
Greenhorn

Joined: Apr 28, 2009
Posts: 3
Nidhi Singhal wrote:With hibernate, you can do batch updates - it reduces the database roundtrips.


But my application is selecting not update.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Perforarmance diff bet hibernate and JDBC