So I have this method which runs fine + snappy with explicit in-memory data structures, but I've put it into datamapper and it just takes forever.
In my Blog class, sometimes I need to do a funky method, foo, that loops through all the posts, and then further loops through some more qualities which imply other posts that need to be looped through. It should take something like O(posts^2) time. So I have a method in the Blog class which does something like: def foo posts.each{|post| qualities = post.qualities.transform_in_some_way # number of qualities of each post is bounded by the total # of posts qualities.each{|quality| otherpost = posts.first(:quality => quality) # I can guarantee otherpost never == post because of the transform # I can also guarantee otherpost is unique x = otherpost.propertya if some_condition? y = otherpost.propertyb if another_condition? } post.update({:propertya => x, :propertyb => y}) } end This runs very slowly, but not because of the posts^2 operations. In particular, 2/3 of the time in foo appears to be taken in the call to update() (i.e., commenting out the update() call makes it run 3x faster). I've tried looking at the individual SQL calls corresponding to the updates with the :debug logger, and they seem to take less than 1/10th the time that DM requires to process them. Any thoughts? -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamap...@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.