-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Performance problem: 15050% slower.
PostPosted: Thu Sep 29, 2005 10:33 am 
Newbie

Joined: Thu Feb 10, 2005 2:33 pm
Posts: 7
Hello.

This difference appears on executing querys directly on database, getting the connection from a hibernate session. It takes 606 milliseconds in average to run every query through hibernate's connection. While running the same querys creating a new connection (without hibernate), the execution time is 4 milliseconds in average.
Below is the code used to run the querys.
There are about 7000 querys, what takes about 1:10 hour to run with hibernate, against 32.4 seconds without it.

Code:
       Transaction tx=null;
      try{
         tx = session.beginTransaction();
         Connection con = session.connection();
         con.setAutoCommit(false);
         Statement stmt = con.createStatement();
         for (Iterator iter = dtos.iterator(); iter.hasNext();) {
            IntegracaoEstabDTO dto = (IntegracaoEstabDTO) iter.next();
            stmt.addBatch("update Estabelecimento set totalAlunos = " + dto.getTotalAlunos() + " where municipio.codigo = " + dto.getCodigoMunicipio() + " and codigoEstabelecimento = " + dto.getCodigoEstabelecimento());
         }
         stmt.executeBatch();
         con.commit();
         stmt.close();
         session.flush();
         tx.commit();
         con.setAutoCommit(true);
      }
      catch(HibernateException he){ .....



Is something wrong with my code?
Or that performance is normal for querys with hibernate, what makes its use prohibitive?

Thanks in advice!

Danilo Kovalechyn.

Hibernate version:2.1.6

Name and version of the database you are using: PostgreSQL 7.4.1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 10:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
we just return the connection that the underlying connection manager have given us...should not make any difference.



/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 11:01 am 
Newbie

Joined: Thu Feb 10, 2005 2:33 pm
Posts: 7
Would it be a problem with the database connection pool I'm using,
wich is Apache Commons DBCP?
The strange is that, with operations using hibernate in a "regular way" (instantiating classes,etc), the performance is good.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 11:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dont know - put a profiler on it and see what pops up.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.