Hi,
I've read on railsexpress that one of the bottleneck of rails
performances is building ActiveRecord object from big complex querys.
So I wanted to use the select statement to ease it up a bit, but I came
to realize that :select isn't used when :include is in
ex : Book.find(:all, :select=>'books.title') works
ex : Book.find(:all, :select=>'books.title', :include=>[:author]) gives
me every single column.
Is their a (simple) workaround, am i doing anything wrong ?
just did a google and got this: http://dev.rubyonrails.org/ticket/5371
Seems it's a bug. I've been working with rails for a year now, but i'm
an amateur programmer and digging in to core is out my scope.
Hope somebody gets on that one
If you think about what's happening with the SQL command when querying
with and :include, it makes sense.
If you just selected "books.title", then it wouldn't get any of the
author columns and couldn't populate the author object. What you
probably want in the end is something like "books.title, authors.name".
In the long run, I don't think selecting all the columns is a very
large performance hit, I'd test the trade off between eager loading
(:include) and limiting you select columns (:select). I suspect that
the eager loading will give you better results.