Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10978 (closed enhancement: fixed)

Opened 7 months ago

Last modified 7 months ago

Do not clone attributes when constructing SQL insert and update statements

Reported by: adymo Assigned to: technoweenie
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc:

Description

Both ActiveRecord::Base::create and ActiveRecord::Base::update both call ActiveRecord::Base::attributes_with_quotes and that clones attributes every time. Attached patch avoids cloning and improves performance of AR::Base::save.

Attachments

ar_dont_clone_attributes.patch (1.0 kB) - added by adymo on 02/01/08 18:50:13.
efficient_attributes_with_quotes.diff (1.8 kB) - added by technoweenie on 02/01/08 19:55:23.

Change History

02/01/08 18:50:13 changed by adymo

  • attachment ar_dont_clone_attributes.patch added.

02/01/08 19:55:23 changed by technoweenie

  • attachment efficient_attributes_with_quotes.diff added.

02/01/08 20:01:42 changed by adymo

We have two blog posts describing the effect of this and similar fixes: http://blog.pluron.com/2008/01/ruby-on-rails-i.html http://blog.pluron.com/2008/01/guerrillas-way.html

02/01/08 20:03:52 changed by technoweenie

  • owner changed from core to technoweenie.
  • status changed from new to assigned.

+1

02/01/08 23:16:01 changed by nzkoz

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [8770]) Avoid Base#attributes when saving / creating records. Closes #10978 [adymo]