you can also fire scalar queries to count what needs counting.
and use MultiQuery to run all of these in a single roundtrip
On Tue, Sep 23, 2008 at 2:24 AM, Will Shaver <[EMAIL PROTECTED]> wrote:
>
> If you know that you're going to need to serialize ALL of the children
> of a graph, you could session.Get() all levels of the graph at the
> start of the call. NH will then link the entities up for you and avoid
> return trips to the DB. Unless your entities are HUGE (blob size
> binary data) then generally returning 10,000 rows in one query is much
> faster than numerous round trips for fewer entities.
>
> If the entities are from different tables, and you only need to load
> some of them this becomes more tricky, but still can be accomplished
> by multiple outer joins in a criteria/hql query. Even if you don't use
> the results, running the query should speed up your graph traversal.
>
>
> On Mon, Sep 22, 2008 at 4:12 PM, gatapia <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > I need to serialise a data tree however the performance of this is
> > understandable poor as all children must be fetched prior to
> > serialisation. I was looking for a better performing way of doing
> > this.
> >
> > Currently before serialising a child collection I check wether the
> > collection is empty by:
> >
> > if(NHibernate.NHibernateUtil.IsInitialized(Children)) { return
> > Children.Count() > 0; }
> > NHibernate.IQuery q = GetSession().CreateFilter(Children, "Select
> > count(*)");
> > return Convert.ToInt32(q.UniqueResult()) > 0;
> >
> > This greatly improves performance over a straight call to
> > Children.Count() but I still think there must be a better way of doing
> > this.
> >
> > If an Entity has 2+ children collections can I get their count in one
> > database call?
> >
> > Any other suggestions?
> >
> > Thanks
> >
> > Guido Tapia
> > >
> >
>
> >
>
--
Ken Egozi.
http://www.kenegozi.com/blog
http://www.musicglue.com
http://www.castleproject.org
http://www.gotfriends.co.il
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---