<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Ruby on Rails Polymorphic Association Benchmarks</title>
	<atom:link href="http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<pubDate>Thu, 04 Dec 2008 18:33:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7-bleeding</generator>
		<item>
		<title>By: Xavier Shay</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-70</link>
		<dc:creator>Xavier Shay</dc:creator>
		<pubDate>Sun, 15 Jun 2008 02:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-70</guid>
		<description>You likely can use the SET datatype - it basically gives you strings but stores them internally as integers. We've hacked the enum-column plugin to support it for mysql - haven't tried with polymorphics yet, but it works fine with STI, which I presume is similar code. It's too ugly for public consumption at the moment but if you're interested drop me a line.</description>
		<content:encoded><![CDATA[<p>You likely can use the SET datatype - it basically gives you strings but stores them internally as integers. We&#8217;ve hacked the enum-column plugin to support it for mysql - haven&#8217;t tried with polymorphics yet, but it works fine with STI, which I presume is similar code. It&#8217;s too ugly for public consumption at the moment but if you&#8217;re interested drop me a line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Gauthier</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-69</link>
		<dc:creator>Nick Gauthier</dc:creator>
		<pubDate>Sat, 14 Jun 2008 22:32:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-69</guid>
		<description>@David: Right, the int key vs string key is a small percentage. 57 vs 51 in your case.

@Dan (and everyone): Please add tests to the code base, we'll all benefit from more benchmarks!

-Nick</description>
		<content:encoded><![CDATA[<p>@David: Right, the int key vs string key is a small percentage. 57 vs 51 in your case.</p>
<p>@Dan (and everyone): Please add tests to the code base, we&#8217;ll all benefit from more benchmarks!</p>
<p>-Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Dai</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-68</link>
		<dc:creator>David Dai</dc:creator>
		<pubDate>Sat, 14 Jun 2008 21:23:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-68</guid>
		<description>To clarify, I mean Integer key VS string key. Not indexed VS non-indexed.</description>
		<content:encoded><![CDATA[<p>To clarify, I mean Integer key VS string key. Not indexed VS non-indexed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Dai</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-67</link>
		<dc:creator>David Dai</dc:creator>
		<pubDate>Sat, 14 Jun 2008 21:15:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-67</guid>
		<description>I ran it on 10,000 rows on my mac book pro 2.6GHz Core2 Duo, 4GB RAM with MySQL:

http://pastie.org/215147

I don't see much of a difference.</description>
		<content:encoded><![CDATA[<p>I ran it on 10,000 rows on my mac book pro 2.6GHz Core2 Duo, 4GB RAM with MySQL:</p>
<p><a href="http://pastie.org/215147" rel="nofollow">http://pastie.org/215147</a></p>
<p>I don&#8217;t see much of a difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Kubb</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-66</link>
		<dc:creator>Dan Kubb</dc:creator>
		<pubDate>Sat, 14 Jun 2008 19:03:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-66</guid>
		<description>Another suggestion: you should benchmark this approach against the old-school approach of using an explicit join table between the two tables, since it's the classic alternative to polymorphic associations and would provide a nice baseline.

I personally am still inclined to use a join table rather than polymorphic associations.  It's very rare that I have something that needs to be "promiscuous" enough that I won't be able to know up-front what needs to be joined to what.  I tend to prefer it because I can add constraints to the join table to ensure one side is unique, for example.  It also leaves room open in case I need to add other information to the relationship (as I often do) such as the time the relationship was created/updated, etc.</description>
		<content:encoded><![CDATA[<p>Another suggestion: you should benchmark this approach against the old-school approach of using an explicit join table between the two tables, since it&#8217;s the classic alternative to polymorphic associations and would provide a nice baseline.</p>
<p>I personally am still inclined to use a join table rather than polymorphic associations.  It&#8217;s very rare that I have something that needs to be &#8220;promiscuous&#8221; enough that I won&#8217;t be able to know up-front what needs to be joined to what.  I tend to prefer it because I can add constraints to the join table to ensure one side is unique, for example.  It also leaves room open in case I need to add other information to the relationship (as I often do) such as the time the relationship was created/updated, etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Gauthier</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-65</link>
		<dc:creator>Nick Gauthier</dc:creator>
		<pubDate>Sat, 14 Jun 2008 14:21:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-65</guid>
		<description>Hey Eric,

I was thinking about that too. When the current benchmark finishes I'll add in two more tables with full indexing (unless you want to do it :-D).

-Nick</description>
		<content:encoded><![CDATA[<p>Hey Eric,</p>
<p>I was thinking about that too. When the current benchmark finishes I&#8217;ll add in two more tables with full indexing (unless you want to do it :-D).</p>
<p>-Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Allam</title>
		<link>http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-64</link>
		<dc:creator>Eric Allam</dc:creator>
		<pubDate>Sat, 14 Jun 2008 13:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/2008/06/13/ruby-on-rails-polymorphic-association-benchmarks/#comment-64</guid>
		<description>Usually you'd want to create an index that indexes on both the type and the id columns.</description>
		<content:encoded><![CDATA[<p>Usually you&#8217;d want to create an index that indexes on both the type and the id columns.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
