The document Relation#update(id, attributes) docs mentions that "the resulting object is returned regardless of whether the object was successfully stored in the database or not", while Relation#update_all(updates, conditions = nil, options = {}) declares that no instances, callbacks or checks are performed (direct database request).
By performing a simple performance test and replacing Relation#update with Relation#update_all , it seems that memory consumption has increased.
Any explanation?
Excerpts:
#Before MyModel.update(my_hash['id'], special_attrs)
- Windows XP (yeh - I know)
- JRuby 1.6.8 (1.9)
- Rails 3.2.8
UPDATE . Some basic numbers for comparison: For about 700 update applications, there is a difference of about 0.6MB (0.8kB per operator)
UPDATE 2 . Removed AREL chain as suggested by @ philip-hallstrom. A slight decrease in memory, but still MyModel.update_all(attrs, conditions) consumes more memory than MyModel.update(id, attrs) .
source share