-->
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: Query.setFetchSize seems not work for PostgreSQL
PostPosted: Wed Sep 14, 2005 7:05 am 
Newbie

Joined: Tue Sep 06, 2005 4:12 am
Posts: 16
I am using pg74.216.jdbc3.jar driver to access PostgreSQL db. I try to select all records in a table which has 100,000 records to inspect the performance with setFetchSize() mechanism.

My code like this:
Code:
public static void pagingSelect(int fetchSize, int displayCount){
   Session session = ConnectionBean.getCurrentSession();
   Query query = session.createQuery("from Customer");
   query.setFetchSize(fetchSize);
      
   System.out.println("Start loading...");
   Iterator customerIterator = query.list().iterator();
   int i = 0;
   while (customerIterator.hasNext()) {
      Customer customer = (Customer)customerIterator.next();
      System.out.println(customer.getId() + ",\t" + customer.getCompany());
      i++;
      if (i == displayCount)
         break;
   }
   session.close();
   System.out.println("End loading.");
}

But when it is running query.list().iterator(), it takes a several minutes and raise OutOfMemory error. Obviously, setFetchSize() doesn't takes effect.

I have already set lazy="true" in Customer.hbm.xml mapping file.

What's wrong for this? Thank you very much.

--
Best regards,
Diviner.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 19, 2005 11:57 pm 
Newbie

Joined: Tue Sep 06, 2005 4:12 am
Posts: 16
Any comments?


Top
 Profile  
 
 Post subject: Did you get your question answered on setFetchSize
PostPosted: Thu Jan 19, 2006 10:49 pm 
Newbie

Joined: Tue Sep 06, 2005 5:04 pm
Posts: 15
Please let me know.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 20, 2006 12:33 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Turn on show_sql, and have a look at the output. According to the dialect, you should see "limit ?" or "limit ? offset ?" in the sql. If you don't, then something's wrong.

Given that you're writing test code, why don't you just print query.list().size()?


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.