-->
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.  [ 10 posts ] 
Author Message
 Post subject: Fetch All Remote is slow
PostPosted: Sun Sep 08, 2013 11:35 pm 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
Hi

I have a table with three columns. It contains 30,000 records. When I am trying to retrieve all these records. It is taking 20 minutes. It doesn't contain any primary key.

When I retrieve the same from JDBC, it is taking less than a minute.
Here the database exists remotely.

How to reduce the retrieval time?

Thanks
NavaJyothi


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Wed Sep 18, 2013 4:20 am 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
any comments on the above problem?


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Wed Sep 18, 2013 5:34 am 
Newbie

Joined: Wed Sep 18, 2013 5:12 am
Posts: 6
plz do post peace of code u do in hibernate and as well as in jdbc.


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Wed Sep 18, 2013 5:59 am 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
List<Users> events = null;
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();
session.beginTransaction();
long startTime = System.currentTimeMillis();
try {
Query query = session
.createSQLQuery(
"select * from Users")
.addEntity(Users.class);
events = query.list();
} catch (Exception queryException) {
session.getTransaction().rollback();
} finally {
session.getTransaction().commit();
session.close();
}
long endTime = System.currentTimeMillis();
System.out.println("Time Taken:"
+ (((endTime - startTime))));
return events;


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Thu Sep 19, 2013 9:28 am 
Newbie

Joined: Wed Sep 18, 2013 5:12 am
Posts: 6
I'm not sure but you can try these two things.

1. Criteria API
Criteria c=createCriteria(Stock.class)
List <Stock> stock=c.list();

2. If u have child tables you can use this in your native sql query.
select s.* from Stock s in native sql.


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Fri Sep 20, 2013 2:43 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Please show the SQL Hibernate executes.


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Fri Sep 20, 2013 8:03 am 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
select * from USERS
I have also tried giving individual columns


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Fri Sep 20, 2013 8:05 am 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
Hi shaikeliasmca,

I have tried yours. Even for that it is taking 19 minutes. Any other things you want me to try?


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Fri Sep 20, 2013 8:12 am 
Newbie

Joined: Wed Jun 05, 2013 8:57 am
Posts: 7
Hi shaikeliasmca,

I have tried yours. Even for that it is taking 19 minutes. Any other things you want me to try?


Top
 Profile  
 
 Post subject: Re: Fetch All Remote is slow
PostPosted: Fri Sep 20, 2013 10:07 am 
Newbie

Joined: Wed Sep 18, 2013 5:12 am
Posts: 6
http://www.developersfusion.com/Default.aspx


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