On Sun, Sep 11, 2011 at 5:18 PM, Walter Lee Davis <wa...@wdstudio.com> wrote: > On Sep 11, 2011, at 11:45 AM, John Merlino wrote: > >> thanks for response. What you said explained a lot. >> >> Now I have never seen rails code written like that. Would it have been >> better to do this: >> >> @b.map(&:a_group).compact.uniq >>
Depends. What that does is pull back all the results and then compact/uniq them in ruby -- whereas adding the where clause in the first example limits the number of rows brought back from the database. If there are a lot of rows in the database (1000's or maybe even millions of rows) this may be a substantial difference. If there are a few hundred or less rows, it doesn't make that big of a difference. But in general, I'd say that an approach that limits what's brought back from the database is probably better. Kevin Bedell Boston Agile Partners @kbedell -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.