Phoenix Rising
2011-May-03 03:13 UTC
Database performance for polymorphic associations under high load
Hey guys, I''ve been thinking lately about polymorphic associations, and I wonder: is there a noticeable or tangible performance "hit" from doing polymorphic associations when you''ve got your database under really high query load? So for example, maybe I have a "message" model, a "user" model and an "administrator" model, without any subclassing or STI going on. Message has a polymorphic interface called "message_author", and both "User" and "Administrator" use it. Say there wind up being ~1 million messages in that message table. Assuming everything''s properly indexed, do polymorphic associations add any significant overhead to conducting database queries? Thanks guys, appreciate the input. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Me
2011-May-03 03:20 UTC
Re: Database performance for polymorphic associations under high load
I would stay away from polymorphic as there is no way to enforce DB FK relationships. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Phoenix Rising
2011-May-03 03:25 UTC
Re: Database performance for polymorphic associations under high load
That''s been my "official" stance for a while as well, and I''m fully aware of that - but I''m also wondering about its performance, so I can get a better perspective of the "full picture", if you follow my logic. Still, your point is quite valid and has been taken under advisement. Thank you. On May 2, 9:20 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would stay away from polymorphic as there is no way to enforce DB FK > relationships.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.