I have a Team table /entity with a parentId which is an id that self joined into the same table.
There is a property called TopUnit that will recursizely keep calling .Parent until it finds an attribute on the Team entity called “IsTopUnit”
using the nhibernate profiler this is now causing an Select N + 1 alert. is there anyway to optimize what is essentially a recursize self join query to avoid the Select N + 1 behavior.
batchsize seems to work for child collections but it doesn’t seems to help in this case as its all “syncronous” as i can’t do a recursize SQL statement.
I guess this question is valid outside of nhibernate as well. What is the best way to do recursive statements in SQL. it seems like you would have to break it up into multiple queries.
You can try this http://ayende.com/Blog/archive/2009/08/28/nhibernate-tips-amp-tricks-efficiently-selecting-a-tree.aspx