• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Perforarmance diff bet hibernate and JDBC

 
Prasanna Sankar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With hibernate, you can do batch updates - it reduces the database roundtrips.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nidhi Singhal wrote:With hibernate, you can do batch updates - it reduces the database roundtrips.


But my application is selecting not update.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic