On Feb 23, 2:17 pm, Jeremy Evans <[email protected]> wrote:
> I had to add a couple small commits after testing on MySQL, but
> otherwise the perf branch appears to work fine.  It even fixes a bug
> with the H2 JDBC subadapter in regards to literalizing dates.  I'm
> going to leave the perf branch out for commits a little longer.
> Unless I hear complaints, I will probably be merging it later this
> week.

I just refactored the Model.[] optimization.  I don't think it'll have
a significant performance effect, but it should fix a couple bugs in
the previous version.

Also, if anyone wants to test out the following patch and see if it
speeds up eager loading of multiple associations at once (via .eager,
not .eager_graph), let me know how it affects performance.   What the
patch does is load each eagerly loaded association in a separate
thread.

diff --git a/lib/sequel_model/eager_loading.rb b/lib/sequel_model/
eager_loading.rb
index 0d61634..9248c57 100644
--- a/lib/sequel_model/eager_loading.rb
+++ b/lib/sequel_model/eager_loading.rb
@@ -355,10 +355,13 @@ module Sequel::Model::Associations::EagerLoading
       end
     end

-    reflections.each do |r|
-      r[:eager_loader].call(key_hash, a, eager_assoc[r[:name]])
-      a.each{|object| object.send(:run_association_callbacks,
r, :after_load, object.associations[r[:name]])} unless r
[:after_load].empty?
+    threads = reflections.map do |r|
+      Thread.new do
+        r[:eager_loader].call(key_hash, a, eager_assoc[r[:name]])
+        a.each{|object| object.send(:run_association_callbacks,
r, :after_load, object.associations[r[:name]])} unless r
[:after_load].empty?
+      end
     end
+    threads.each{|t| t.join}
   end

   # Build associations from the graph if #eager_graph was used,

My limited benchmarking shows no real change in performance, so I
don't plan to investigate this further.  At most it'll be an option in
a future version, off by default, due to likely race conditions since
the associations code wasn't designed with this in mind.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" 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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to