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.  [ 1 post ] 
Author Message
 Post subject: Large number of selects taking long time to execute.
PostPosted: Mon Nov 06, 2006 10:45 am 
Newbie

Joined: Mon Nov 06, 2006 10:22 am
Posts: 2
Hello,
The scenario here is that I would have to query the database to select a row based on three conditions (conjunctions). And there are thousands (10,000 nearly) of such transactions. It takes a long time to execute these transactions.
When doing a batch select(broader select with just one where condition) it takes less that a second to return, though a huge list is returned.
Also, execution of thousands of select statment using mysql preparedStatement doesnt take too much time at all.
So I fear there should be a serious problem with the way we approach hibernate.
Please clarify.
The details are below:

Hibernate version:
3
Mapping documents:
<class name="AdComponent" table="AdComponent">
<id name="id" column="ID" type="long">
<generator class="identity"/>
</id>
<property name="ComponentTypeID" column = "ComponentTypeID" type="integer"/>
<property name="ComponentID" column = "ComponentID" type="long"/>
<property name="AdID" column = "AdID" type="long"/>
....
<query name="getAdComponentByCriteria"><![CDATA[
from AdComponent where AdID = :AdID and ComponentID = :ComponentID and ComponentTypeID = :ComponentTypeID
]]></query>
...
Code between sessionFactory.openSession() and session.close():
Transaction txn = relDBSession.beginTransaction();
Query hq = relDBSession.getNamedQuery("getAdComponentByCriteria");
hq.setLong("AdID", AdID);
hq.setInteger("ComponentTypeID", ComponentTypeID);
hq.setLong("ComponentID", ComponentID);
AdComponent ac = (AdComponent) hq.uniqueResult();
if(ac != null)
ac.getPriority();
txn.commit();
Name and version of the database you are using:
mysql 5
The generated SQL (show_sql=true):
select adcomponen0_.ID as ID13_, adcomponen0_.ComponentTypeID as Componen2_13_, adcomponen0_.ComponentID as Componen3_13_, adcomponen0_.AdID as AdID13_, adcomponen0_.CheckSum as CheckSum13_, adcomponen0_.RelevancyScore as Relevanc6_13_, adcomponen0_.Priority as Priority13_, adcomponen0_.StatusID as StatusID13_, adcomponen0_.ReqTimeStamp as ReqTimeS9_13_ from AdComponent adcomponen0_ where adcomponen0_.AdID=? and adcomponen0_.ComponentID=? and adcomponen0_.ComponentTypeID=?


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

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.