You have to use lazy loading. With the current mapping, if you load one sample, AR loads all the tests assigned to it, then for every test it loads all the machines associated with them and then for all machines of all tests of this sample it loads all results.
If you had many-to-many relationships, this would be even worse, because then all other reachable tests, computers and samples would be loaded. But even so, you are getting a good bunch of data into memory with a lot of queries. Performancewise, all HasMany-attributes should have Lazy=true and Inverse=true. Ayende has written some posts on inverse and lazyloading for NHibernate. Since AR uses NH, these posts are very useful. You might also want to try NHProf for performance profiling with AR if lazy loading does not bring enough performance. -Markus 2010/5/29 raghavsri <[email protected]> > In sample class to map sample > > [HasMany(typeof(Test), Table = "Test", ColumnKey = "SID", Inverse = > false, > Cascade = ManyRelationCascadeEnum.All)] > > In test class to map sample > [BelongsTo("SID", NotNull = true)] > public virtual Sample Sample > > in test class to map mahcine > [HasMany(Table = "Machine", ColumnKey = "TID", Inverse = false, > Cascade = ManyRelationCascadeEnum.All)] > > in machine class to map test > [BelongsTo("TID", NotNull = true)] > public virtual Test Test > > > > On May 29, 2:48 am, raghavsri <[email protected]> wrote: > > following are the list of table > > sample--->test-->machine--->result > > user > > > > sample has 1 to many relationship with test , > > test ,1 to many to machine > > machine ,1 to many result > > > > apart from this test is also associated with user table > > > > I have inserted more than 1000 rows in all these table > > > > when i say > > ActiveRecordBase<Sample>.FindOne > > ( > > new ICriterion[] > > { > > Expression.Eq("SerialNumber", serialNumber) > > } > > ); > > > > it is taking lot of time, > > > > On May 29, 2:17 am, Markus Zywitza <[email protected]> wrote: > > > > > > > > > Sorry, my crystal ball is off duty right now. Can you please send us > your > > > mappings and your usage scenario? > > > > > -Markus > > > > > 2010/5/28 raghavsri <[email protected]> > > > > > > Hi > > > > I am experiencing very poor peformance ,when i am using FindOne and > > > > FindAll fucntionality ,in activerecord. > > > > there are only 4 cascaded tables and these functions are taking more > > > > time even with small amount of data(1000 Rows in database. ) > > > > Please can somebody tell me ,what is the actual problem. ?(Logging is > > > > switched off) > > > > Regards > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups > > > > "Castle Project Users" group. > > > > To post to this group, send email to > [email protected] > > > > . > > > > To unsubscribe from this group, send email to > > > > [email protected]<castle-project-users%[email protected]> > <castle-project-users%2bun[email protected]> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/castle-project-users?hl=en.-Hidequoted > > > >text - > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" group. > To post to this group, send email to [email protected] > . > To unsubscribe from this group, send email to > [email protected]<castle-project-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/castle-project-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en.
