<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MySQL InnoDB Clustered Indexes and Rails</title>
	<atom:link href="http://www.joehruska.com/?feed=rss2&#038;p=6" rel="self" type="application/rss+xml" />
	<link>http://www.joehruska.com/?p=6</link>
	<description>What do I want to be when I grow up?</description>
	<lastBuildDate>Mon, 16 Aug 2010 21:08:28 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Mysql Database Software</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-19</link>
		<dc:creator>Mysql Database Software</dc:creator>
		<pubDate>Wed, 02 Apr 2008 03:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-19</guid>
		<description>I found your post here very informative. I&#039;m gonna look around your site a bit and see if I can find more info on Mysql Database Software. If anybody else here knows of a good site to find info on Mysql Database Software please let me know. thanks.</description>
		<content:encoded><![CDATA[<p>I found your post here very informative. I&#8217;m gonna look around your site a bit and see if I can find more info on Mysql Database Software. If anybody else here knows of a good site to find info on Mysql Database Software please let me know. thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-15</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Wed, 12 Mar 2008 14:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-15</guid>
		<description>@Ilya

For InnoDB table maintenance, one of the really important my.cnf parameters is innodb_file_per_table.  This will create a [tablename].ibd file for each of your InnoDB tables instead of putting it all in one really large ibdataX file.  This way, you can optimize the table to recover space without dumping and reimporting.  Hope that helps!</description>
		<content:encoded><![CDATA[<p>@Ilya</p>
<p>For InnoDB table maintenance, one of the really important my.cnf parameters is innodb_file_per_table.  This will create a [tablename].ibd file for each of your InnoDB tables instead of putting it all in one really large ibdataX file.  This way, you can optimize the table to recover space without dumping and reimporting.  Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilya Grigorik</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-14</link>
		<dc:creator>Ilya Grigorik</dc:creator>
		<pubDate>Wed, 12 Mar 2008 12:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-14</guid>
		<description>How did you guys decrease your tablespace size? In all of my tests (InnoDB specifically), the only way to get the size down is via complete mysqldump and reimport. 

I&#039;ll also second the partitioning comment - it sounds like you guys can get a lot of benefit from it. Likewise, I&#039;d look at ARCHIVE engine. 

Great post!</description>
		<content:encoded><![CDATA[<p>How did you guys decrease your tablespace size? In all of my tests (InnoDB specifically), the only way to get the size down is via complete mysqldump and reimport. </p>
<p>I&#8217;ll also second the partitioning comment &#8211; it sounds like you guys can get a lot of benefit from it. Likewise, I&#8217;d look at ARCHIVE engine. </p>
<p>Great post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-13</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Wed, 12 Mar 2008 06:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-13</guid>
		<description>@Eduardo

The primary difference on the EC2 instance was that I had 15GB of InnoDB buffer to play with, vs the 2GB InnoDB buffer on our our normal DB server.  I&#039;m not quite sure of how much time was saved overall, since I was never able to complete the table restructuring on our test server before MySQL crashed due to lack of memory.</description>
		<content:encoded><![CDATA[<p>@Eduardo</p>
<p>The primary difference on the EC2 instance was that I had 15GB of InnoDB buffer to play with, vs the 2GB InnoDB buffer on our our normal DB server.  I&#8217;m not quite sure of how much time was saved overall, since I was never able to complete the table restructuring on our test server before MySQL crashed due to lack of memory.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eduardo Rocha</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-12</link>
		<dc:creator>Eduardo Rocha</dc:creator>
		<pubDate>Wed, 12 Mar 2008 04:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-12</guid>
		<description>Joe, the reindex process seems to be mostly IO bound. How could your powerful EC2 instance help the rebuild?</description>
		<content:encoded><![CDATA[<p>Joe, the reindex process seems to be mostly IO bound. How could your powerful EC2 instance help the rebuild?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-11</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:25:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-11</guid>
		<description>@software.simian

1.  Actually the ability to merge indexes came out with MySQL 5.0, so it is now possible to use more than one index at a time within a single query.

2.  It is possible that running the optimize table alone could have had a positive affect on performance, but it was not the major factor here.  InnoDB tables are a lot less prone to row fragmentation due to the implied clustered index.  Deletes out of this particular table that I use as an example are very rare.

3.  Partitioning, oh yeah - that is one of the near term plans for our overall database structure.  With MySQL 5.1&#039;s introduction of partitions, this is something I want to take advantage soon (once I get around to upgrading to 5.1)</description>
		<content:encoded><![CDATA[<p>@software.simian</p>
<p>1.  Actually the ability to merge indexes came out with MySQL 5.0, so it is now possible to use more than one index at a time within a single query.</p>
<p>2.  It is possible that running the optimize table alone could have had a positive affect on performance, but it was not the major factor here.  InnoDB tables are a lot less prone to row fragmentation due to the implied clustered index.  Deletes out of this particular table that I use as an example are very rare.</p>
<p>3.  Partitioning, oh yeah &#8211; that is one of the near term plans for our overall database structure.  With MySQL 5.1&#8217;s introduction of partitions, this is something I want to take advantage soon (once I get around to upgrading to 5.1)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: software.simian</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-10</link>
		<dc:creator>software.simian</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-10</guid>
		<description>I found the experience interesting but I found it quite questionable, because

1. you are starting from a bad setup; only index at a time can be used, so there is not need to keep all the indexes there were.

2. you optimized the table, which can make quite a difference, especially if there is fragmentation.
I&#039;m not sure, but it&#039;s possible that this can reduce also the size of the table, reducing the unused space in the blocks. 

Seems like that the table you are talking about is quite static, have you thought about partitioning? It can improve the performance even more.

Cheers, saverio</description>
		<content:encoded><![CDATA[<p>I found the experience interesting but I found it quite questionable, because</p>
<p>1. you are starting from a bad setup; only index at a time can be used, so there is not need to keep all the indexes there were.</p>
<p>2. you optimized the table, which can make quite a difference, especially if there is fragmentation.<br />
I&#8217;m not sure, but it&#8217;s possible that this can reduce also the size of the table, reducing the unused space in the blocks. </p>
<p>Seems like that the table you are talking about is quite static, have you thought about partitioning? It can improve the performance even more.</p>
<p>Cheers, saverio</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-9</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 10 Mar 2008 19:59:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-9</guid>
		<description>@Suleman,

Actually I &quot;cheated&quot; a bit on the table rebuilds.  The first thing I did was to setup a slave replicated instance on an EC2 xlarge instance (15GB RAM/4 Processors).  When I brought the system down for the re-index I did all of the work on the EC2 instance, which had a lot more power than our primary DB server.

I then dropped all of the indexes on the summary tables - which decreased the overall size of the table to less than half.  Once the indexes were gone, I dropped the ID column and added the new composite primary key - this actually ran quite quickly.  After the new primary key was there, I ran an optimize on the table.

The sql I used was:

select now();

alter table duration_summaries
	drop index user_id,
	drop index durationable_id,
	drop index summary_date,
	drop index week,
	drop index month,
	drop index year,
	drop index user_week_year,
	drop index user_month_year,
	drop index date_user_dur_idx,
	modify column user_id int(11) first,
	modify column durationable_id int(11) after summary_date;
	
select now();

alter table duration_summaries
	drop column id,
	drop primary key,
	add primary key (user_id, summary_date, durationable_id);

select now();

optimize table duration_summaries;

select now();</description>
		<content:encoded><![CDATA[<p>@Suleman,</p>
<p>Actually I &#8220;cheated&#8221; a bit on the table rebuilds.  The first thing I did was to setup a slave replicated instance on an EC2 xlarge instance (15GB RAM/4 Processors).  When I brought the system down for the re-index I did all of the work on the EC2 instance, which had a lot more power than our primary DB server.</p>
<p>I then dropped all of the indexes on the summary tables &#8211; which decreased the overall size of the table to less than half.  Once the indexes were gone, I dropped the ID column and added the new composite primary key &#8211; this actually ran quite quickly.  After the new primary key was there, I ran an optimize on the table.</p>
<p>The sql I used was:</p>
<p>select now();</p>
<p>alter table duration_summaries<br />
	drop index user_id,<br />
	drop index durationable_id,<br />
	drop index summary_date,<br />
	drop index week,<br />
	drop index month,<br />
	drop index year,<br />
	drop index user_week_year,<br />
	drop index user_month_year,<br />
	drop index date_user_dur_idx,<br />
	modify column user_id int(11) first,<br />
	modify column durationable_id int(11) after summary_date;</p>
<p>select now();</p>
<p>alter table duration_summaries<br />
	drop column id,<br />
	drop primary key,<br />
	add primary key (user_id, summary_date, durationable_id);</p>
<p>select now();</p>
<p>optimize table duration_summaries;</p>
<p>select now();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suleman Ali</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-8</link>
		<dc:creator>Suleman Ali</dc:creator>
		<pubDate>Mon, 10 Mar 2008 19:47:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-8</guid>
		<description>Amazing that rebuilding the table only took a couple hours for what sounds like a 5GB+ table.  

In my limited experience, it takes a lot longer.  I must be doing something wrong.

Can you share precisely how you rebuilt the innodb table?</description>
		<content:encoded><![CDATA[<p>Amazing that rebuilding the table only took a couple hours for what sounds like a 5GB+ table.  </p>
<p>In my limited experience, it takes a lot longer.  I must be doing something wrong.</p>
<p>Can you share precisely how you rebuilt the innodb table?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.joehruska.com/?p=6&#038;cpage=1#comment-7</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 10 Mar 2008 17:56:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.joehruska.com/?p=6#comment-7</guid>
		<description>Joe!  You started a blog!  That&#039;s awesome.  You&#039;re always very helpful and informative at the YC dinners.  Now I get your good advice in blog form too :).</description>
		<content:encoded><![CDATA[<p>Joe!  You started a blog!  That&#8217;s awesome.  You&#8217;re always very helpful and informative at the YC dinners.  Now I get your good advice in blog form too <img src='http://www.joehruska.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
</channel>
</rss>
