-->
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.  [ 3 posts ] 
Author Message
 Post subject: Bad performance on query compared to JDBC
PostPosted: Thu Dec 01, 2005 10:07 am 
Newbie

Joined: Wed Nov 02, 2005 5:44 am
Posts: 4
I wonder why Hibernate and/or Spring apparently adds a lot of overhead for queries. I have Spring Framework 1.2.5 with Hibernate 3 support.

When I run the following query on a table with 144 rows in it:
Code:
List<Resource> resourceList = getHibernateTemplate().find("from Resource");

or
Code:
List<Resource> resourceList = getSession().createSQLQuery("select * from RESOURCE").addEntity(Resource.class).list();

the query takes 120 ms to execute.

When I run
Code:
Connection connection = getSession().connection();
PreparedStatement statement = connection.prepareStatement("select * from RESOURCE");
ResultSet rs = statement.executeQuery();

the query only takes 1 ms!

Am I doing something wrong?

/Patrik


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 11:50 am 
Newbie

Joined: Thu Dec 01, 2005 11:46 am
Posts: 1
The JDBC script does absolutely nothing with the result itself so that's fast.

The hibernate script also creates the objects that are mapped to the table and puts them in that List object. I think that's the reason it takes somewhat longer.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 11:55 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the Performance Q & A.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.