i am wondering if its good to use associations where possible or if its better to avoid them ... my concern is: it could lower the performance of my application (because new methods are added to the models which are not all necessary for me, etc.) as i am new to ror development i need some expertise advice on this .. can it lead to problem when using associations everywhere where possible? thanks for your opinion... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Associations provide a higher level of abstraction for your app. How does adding new methods affect performance? You can optimize slow queries with multiple joins by using sql instead of ActiveRecord finders. There are also other techniques to speed up the app. As a beginner I would not worry. As one of my incompetent manager used to say: "Code like a wind". LOL. On Dec 21, 2007 12:42 PM, Michal Gabrukiewicz < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > i am wondering if its good to use associations where possible or if its > better to avoid them ... > > my concern is: it could lower the performance of my application (because > new methods are added to the models which are not all necessary for me, > etc.) >-- http://www.rubyplus.org/ Free Ruby Screencasts --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks for your quick reply ... so lets say i have a User model which has the following attributes... firstname lastname creator_id updater_id reports_to so the user was created by a user .. and the last modification be done by another user .. then each user reports to one user ... moreover the users have friends, send messages, write blog entries, etc. - would you really add for all this own associations? also e.g. for creator and updater - which are e.g. only used on one place? - i also load the current logged in user on each request .. would this affect performance if more associations are here? i am just wondering, because the project is expecting to have 10.000 uniques a day. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 21 Dec 2007, at 20:58, Michal Gabrukiewicz wrote:> > thanks for your quick reply ... so lets say i have a User model which > has the following attributes... > > firstname > lastname > creator_id > updater_id > reports_to > > so the user was created by a user .. and the last modification be done > by another user .. then each user reports to one user ... moreover the > users have friends, send messages, write blog entries, etc. > > - would you really add for all this own associations? also e.g. for > creator and updater - which are e.g. only used on one place? >probably> - i also load the current logged in user on each request .. would this > affect performance if more associations are here? >Having an association or not isn''t going to affect the loading a single record> i am just wondering, because the project is expecting to have 10.000 > uniques a day.Remember what they say about premature optimization :-) ? Fred> > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> > Remember what they say about premature optimization :-) ? > > Fredyeah you are right .. but thats why i am asking ... if its not that big deal then i will use it all the way :) because its a great feature! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
associations are one of the benefits of using rails. You should be happy to be able to use them! Adam On 12/21/07, Michal Gabrukiewicz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > > > Remember what they say about premature optimization :-) ? > > > > Fred > > yeah you are right .. but thats why i am asking ... if its not that big > deal then i will use it all the way :) because its a great feature! > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> it could lower the performance of my application (because > new methods are added to the models which are not all necessary for meJust to be clear, the number of methods in a class has neglible impact on performance, so I think your concerns about associations are maybe based on a false premise. ///ark --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks.. i wasnt so sure about this. now i am using associations everywhere :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---