Recommendations for optimizing NHibernate with Large Amounts of Data
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?
- Enable Lazy-Load
- Check NHibernate logs to see what is exactly selected or use NHibernate Profiler
- Consider using cache
精彩评论