-->
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: SlicedFindAll and Count optimizations
PostPosted: Thu May 22, 2008 3:29 pm 
Newbie

Joined: Wed Apr 12, 2006 2:13 pm
Posts: 3
hi All,

We're just starting to use nhibernate and are loving it so far. One thing we noticed though is that for slicedfindall you basically have to do 2 separate queries. One to return the slice of data and a second to get the total count of the entire dataset.

Now a lot of databases such as mysql, oracle etc. support returning the total number of rows when doing a slice so you don't have to do another query to get back the total count of records. For our startup we're looking at browsing through 100000s of photos, videos, stats etc. and an optimization where, as part of the select that returns the slice, we also get back the total count would halve the number of queries we're running.

In Mysql there is a column returned as part of a query called SQL_CALC_FOUND_ROWS. Is there any way of accessing that column as part of the slicedfindall? I've looked in quite a few places but haven't found any reference to accessing this in nhibernate or even if it's possible. SQL Server and Oracle have their version of this as well and paging is such a basic thing that such an optimization would make a huge performance difference.

ed


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 22, 2008 8:45 pm 
Newbie

Joined: Wed Jul 20, 2005 12:57 am
Posts: 15
Location: Sydney, Australia
Oren Eini has posted a way to do this on his blog. I've never used MySql but I'd say you could adapt the technique.

http://www.ayende.com/Blog/archive/2007 ... y-way.aspx

_________________
Christian Maslen


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 4:03 am 
Newbie

Joined: Wed Apr 12, 2006 2:13 pm
Posts: 3
Wicked!! Thanks for the info....


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.