开发者

Recommendations for optimizing NHibernate with Large Amounts of Data

开发者 https://www.devze.com 2023-04-09 08:16 出处:网络
I have a rath开发者_开发问答er complex mapping for some of my class objects for NHibernate.I have everything mapping correctly; however, it is taking approximately 10-15 minutes to save the items and

I have a rath开发者_开发问答er complex mapping for some of my class objects for NHibernate. I have everything mapping correctly; however, it is taking approximately 10-15 minutes to save the items and over 21 minutes to load them, which of course is unacceptable.

Here is my situation.

I have 3 classes, lets call them Foo, Bar, and Test. Class Foo has a property that is a list with a many-to-one mapping of class Bar. Bar has a property that is a list with a many-to-many mapping of class Test. Finally Test has a property that is a list with a many-to-many mapping of class Bar. All three classes have various other properties associated with them of other class types which are being loaded.

I currently don't have lazy loading enabled at the moment, which I plan on trying to implement soon, but the problem I am facing is that many of the properties for the 3 classes are needed right away.

My first question is this. I have 250 Foo classes saved, 500 Bar classes, and 1000 Test classes. On loading my first Foo class, it is loading the Bar's that are in its list, which conversely contain a List of all 1000 Test classes, each Test class has a list of all the 500 Bar classes. Is NHibernate data aware enough to know that the 1000 Test classes have been loaded and the 500 Bar classes have already been loaded, so when it moves to the next Foo class it doesn't have to reload all the Bar and Test classes again?

What would you guys recommend to boost the performance?


  1. Enable Lazy-Load
  2. Check NHibernate logs to see what is exactly selected or use NHibernate Profiler
  3. Consider using cache
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号