Thanks for the recommendation, I'm still fairly new to NH and was not aware of the batch size option.
On Mar 7, 1:46 pm, Jason Meckley <[email protected]> wrote: > you wouldn't want to eagerly load all of this in a single query, the results > would not be efficient. I recommend batched select statements. this avoids > n+1 and Cartesian result sets. you would set the batch-size of the mapped > collection to an arbitrary number, like 50. then you can select the list of > root elements and let lazy loading take over. > > say your batch-size is 10 for products to recommendations and 5 for > recommendation to images. session.CreateQuery("from products where > ...").List(); return s 25 products. > 1. select 25 products > 2. select recommendations based on products 1-10 > 3. select recommendations based on products 11-20 > 4. select recommendations base on products 21-25 > > now lets say there are 10 recommendations across 25 products > 5. select images based on recommendations 1-5 > 6. select images based on recommendations 6-10 > > this would issue a total of 6 queries to return 25 products, 10 > recommendations and N images. by adjusting the size of the select batch you > could reduce this to 3 queries. The key is to find a balance between the > size of the result set and the number of queries issued. -- 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.
