Speeding up ActiveRecord

275 views
Skip to first unread message

MikeGehard

unread,
Aug 17, 2012, 8:41:04 AM8/17/12
to rubyonra...@googlegroups.com
Good morning all,

I am wondering if there is any ongoing work to speed up ActiveRecord object instantiation from the database? I am working on a project where we have determined that loading AR records from the database has become a bottleneck in a coupe of spots. To alleviate this we have resorted to raw SQL and hashes.

After reading this article (http://merbist.com/2012/02/23/quick-dive-into-ruby-orm-object-initialization/), it seems to me that if we made the lifecycle hooks optional we could get a little speed bump. They would be on by default but I could turn them off when I declared my AR derived class. 

Any other places that I can help out to make this happen?

Thanks,
Mike

Carlos Eduardo L. Lopes

unread,
Aug 19, 2012, 2:48:37 PM8/19/12
to rubyonra...@googlegroups.com
+1

I don't have too much experience with the AR's internals, but this make sense and is interesting.

If we could choose to turn off the hooks, the model will has better perfomance and spend time on initialization with only what we choose.

--
Carlos Eduardo L. Lopes
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/vBuB-j6nFM4J.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

dburry

unread,
Aug 19, 2012, 7:48:18 PM8/19/12
to rubyonra...@googlegroups.com
I've had great success with the valium and activerecord-import gems, when it comes to a few places where I need to speed things up because I have hundreds or even many thousands of database rows that need processing and when it just so happens that in those cases I don't need full blown AR objects, just an array of a column or two will do just fine...

Dave

MikeGehard

unread,
Aug 24, 2012, 9:32:46 AM8/24/12
to rubyonra...@googlegroups.com
Are these fixes in master or have they already been released in a 3.x version?

On Wednesday, August 22, 2012 3:57:56 AM UTC-6, Bogdan Gusiev wrote:
I've fixed both issues mentioned in this blog post.
If there is any other ideas how we could improve it - please explain them here.

Bogdan Gusiev

unread,
Aug 28, 2012, 2:44:31 AM8/28/12
to rubyonra...@googlegroups.com
Mike, probably not in 3.x

2012/8/24 MikeGehard <mike....@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/tkXzjAyVPDgJ.

To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.



--
Bogdan Gusiev.
agr...@gmail.com

Reply all
Reply to author
Forward
0 new messages