-->
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: paging result in hibernate
PostPosted: Wed Sep 21, 2005 12:48 pm 
Newbie

Joined: Wed Sep 21, 2005 12:37 pm
Posts: 4
Hi,
I'm wondering how the hibernate paging working.
let's say I have a big result(10000 rows) need to be paged.there are functions like setFirstResult(0), setMaxResults(9) in hibernate,

hibernate will
1. only retrieve 10 rows from database, or
2. retrieve 10000 rows and put to a collection,then filter out first 10 rows from the collection.


if Hibernate use the 2nd way, it's still take time for each page even there is only few rows on each page

please explain.
thank you

Joh


Top
 Profile  
 
 Post subject: Re: paging result in hibernate
PostPosted: Wed Sep 21, 2005 3:00 pm 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
richwin wrote:
Hi,
I'm wondering how the hibernate paging working.
let's say I have a big result(10000 rows) need to be paged.there are functions like setFirstResult(0), setMaxResults(9) in hibernate,

hibernate will
1. only retrieve 10 rows from database, or
2. retrieve 10000 rows and put to a collection,then filter out first 10 rows from the collection.


if Hibernate use the 2nd way, it's still take time for each page even there is only few rows on each page

please explain.
thank you

Joh

If you take a look at the SQL Hibernate generates you'll see that it uses option 1. Possibility 2 would kill any application that potentially returns more than a few thousand results.

Erik


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 3:55 pm 
Newbie

Joined: Wed Sep 21, 2005 12:37 pm
Posts: 4
I use hibernate with Oracle,the genarated sql like:

select * from (
select
id ,
col1,
col2,
from
theTable
) where rownum <= ?

this is reasonable since Oracle has rownum.
what if others database(for ex. MS SQL server) doesn't have the similar function?

Thank you for reply


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 1:11 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
With me, the Oracle performance is low using hibernate paging.
The Hibernate generate a subquery, when in this case the subquery is in FROm clause and it´s called as in line view. So, the inline view or subquery read all rows from database and, finally takes the paging.
I think this is a problem with oracle and hibernate paging. :(

_________________
Tads


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.