I pushed push a commit to Sequel that gives a 1.5-2x increase in speed
for #map and #to_hash for model datasets in certain cases (https://
github.com/jeremyevans/sequel/commit/
a321a10d139ba2882bfd18b4962ee31a50e77fc8).
Before, code like:
Album.map(:name)
Album.to_hash(:id, :name)
would create Album objects for each row, even though you were only
interested in the name and/or id fields. While Sequel::Model
instantiation is fast compared to other ruby ORMs, this still caused a
significant performance hit.
This does break backwards compatibility if you were relying on the
behavior. For example, if you overrode after_initialize to change a
column value and you were using map/to_hash on that value. If you are
doing that, switch your map calls to use a block (map{|r| r[:name]},
or build your own hash (h={}; each{|r| h[r[:id]] = r[:name]}).
Note that using map with no arguments or to_hash with one argument
still creates model objects.
If you have any questions/concerns about this commit, please let me
know.
Thanks,
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.