• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Perforarmance diff bet hibernate and JDBC

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 89
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With hibernate, you can do batch updates - it reduces the database roundtrips.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic