<?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: Hacking to make ALTER TABLE online for certain changes</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Aurimas</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-672891</link>
		<dc:creator>Aurimas</dc:creator>
		<pubDate>Tue, 03 Nov 2009 21:05:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-672891</guid>
		<description>@sk - no impact really. Well all SQL statements will be executed if you don&#039;t SET SQL_LOG_BIN=0 but physical rename of .frm files won&#039;t be replicated of course, so I&#039;d recommend doing that separately on master and slaves.</description>
		<content:encoded><![CDATA[<p>@sk &#8211; no impact really. Well all SQL statements will be executed if you don&#8217;t SET SQL_LOG_BIN=0 but physical rename of .frm files won&#8217;t be replicated of course, so I&#8217;d recommend doing that separately on master and slaves.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sk</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-672873</link>
		<dc:creator>sk</dc:creator>
		<pubDate>Tue, 03 Nov 2009 19:53:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-672873</guid>
		<description>I wonder what impact the renaming of files has on MySQL Replication?</description>
		<content:encoded><![CDATA[<p>I wonder what impact the renaming of files has on MySQL Replication?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kedar</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-656538</link>
		<dc:creator>kedar</dc:creator>
		<pubDate>Wed, 23 Sep 2009 12:02:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-656538</guid>
		<description>Hi, This sounded interesting to me.
I managed to create a large table&quot; heavy&quot; to test. 
rows =5000000.
Size  &gt;7GB
OS =windows xp sp2
mysql vesion =5.0.83

Followed the steps as said.
As expected indexes were there in the `show indexes from heavy` but the unexpected &quot;disabled&quot; comment.

I didn&#039;t understand this behaviour!
They&#039;re not at all disabled in the frm that I replaced.

Later I further tried::--

1. Check if indexes are used:- 
mysql&gt; explain select * from heavy where s_arid &gt; 1000 and s_id&gt;30000 limit 10;
+----+-------------+-------+------+---------------+------+---------+------+-----
----+-------------+
&#124; id &#124; select_type &#124; table &#124; type &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows
    &#124; Extra       &#124;
+----+-------------+-------+------+---------------+------+---------+------+-----
----+-------------+
&#124;  1 &#124; SIMPLE      &#124; heavy &#124; ALL  &#124; NULL          &#124; NULL &#124; NULL    &#124; NULL &#124; 5000
000 &#124; Using where &#124;
+----+-------------+-------+------+---------------+------+---------+------+-----
----+-------------+
1 row in set (0.08 sec)


2.. If I need to do something extra??
mysql&gt; analyze table heavy;
+--------------+---------+----------+----------+
&#124; Table        &#124; Op      &#124; Msg_type &#124; Msg_text &#124;
+--------------+---------+----------+----------+
&#124; lyrics.heavy &#124; analyze &#124; status   &#124; OK       &#124;
+--------------+---------+----------+----------+
1 row in set (0.03 sec)

mysql&gt; optimize table heavy;
+--------------+----------+----------+----------+
&#124; Table        &#124; Op       &#124; Msg_type &#124; Msg_text &#124;
+--------------+----------+----------+----------+
&#124; lyrics.heavy &#124; optimize &#124; status   &#124; OK       &#124;
+--------------+----------+----------+----------+
1 row in set (0.06 sec)

But nothing seemed working!

Later I read: 
http://forums.mysql.com/read.php?21,66550,67204#msg-67204
and 
http://dev.mysql.com/doc/refman/5.0/en/myisam-storage-engine.html

Is it the case that my index size is increased beyond limits and hence they&#039;re disabled?</description>
		<content:encoded><![CDATA[<p>Hi, This sounded interesting to me.<br />
I managed to create a large table&#8221; heavy&#8221; to test.<br />
rows =5000000.<br />
Size  &gt;7GB<br />
OS =windows xp sp2<br />
mysql vesion =5.0.83</p>
<p>Followed the steps as said.<br />
As expected indexes were there in the `show indexes from heavy` but the unexpected &#8220;disabled&#8221; comment.</p>
<p>I didn&#8217;t understand this behaviour!<br />
They&#8217;re not at all disabled in the frm that I replaced.</p>
<p>Later I further tried::&#8211;</p>
<p>1. Check if indexes are used:-<br />
mysql&gt; explain select * from heavy where s_arid &gt; 1000 and s_id&gt;30000 limit 10;<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;<br />
&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows<br />
    | Extra       |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;<br />
&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
|  1 | SIMPLE      | heavy | ALL  | NULL          | NULL | NULL    | NULL | 5000<br />
000 | Using where |<br />
+&#8212;-+&#8212;&#8212;&#8212;&#8212;-+&#8212;&#8212;-+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8211;<br />
&#8212;-+&#8212;&#8212;&#8212;&#8212;-+<br />
1 row in set (0.08 sec)</p>
<p>2.. If I need to do something extra??<br />
mysql&gt; analyze table heavy;<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
| Table        | Op      | Msg_type | Msg_text |<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
| lyrics.heavy | analyze | status   | OK       |<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
1 row in set (0.03 sec)</p>
<p>mysql&gt; optimize table heavy;<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
| Table        | Op       | Msg_type | Msg_text |<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
| lyrics.heavy | optimize | status   | OK       |<br />
+&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+<br />
1 row in set (0.06 sec)</p>
<p>But nothing seemed working!</p>
<p>Later I read:<br />
<a href="http://forums.mysql.com/read.php?21,66550,67204#msg-67204" rel="nofollow">http://forums.mysql.com/read.php?21,66550,67204#msg-67204</a><br />
and<br />
<a href="http://dev.mysql.com/doc/refman/5.0/en/myisam-storage-engine.html" rel="nofollow">http://dev.mysql.com/doc/refman/5.0/en/myisam-storage-engine.html</a></p>
<p>Is it the case that my index size is increased beyond limits and hence they&#8217;re disabled?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Faster MySQL failover with SELECT mirroring &#124; MySQL Performance Blog</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-461210</link>
		<dc:creator>Faster MySQL failover with SELECT mirroring &#124; MySQL Performance Blog</dc:creator>
		<pubDate>Sun, 01 Feb 2009 14:13:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-461210</guid>
		<description>[...] this is probably the best general-purpose way to get fast failover and a bunch of other benefits (non-blocking ALTER TABLE, for [...]</description>
		<content:encoded><![CDATA[<p>[...] this is probably the best general-purpose way to get fast failover and a bunch of other benefits (non-blocking ALTER TABLE, for [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Picking datatype for STATUS fields &#124; MySQL Performance Blog</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-343315</link>
		<dc:creator>Picking datatype for STATUS fields &#124; MySQL Performance Blog</dc:creator>
		<pubDate>Mon, 11 Aug 2008 00:16:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-343315</guid>
		<description>[...] (ALTER TABLE) causes table rebuild which is not acceptable for many environments. It is possible to hack this around though I would not like to do this as a standard production practice. It is also worth to note ENUM [...]</description>
		<content:encoded><![CDATA[<p>[...] (ALTER TABLE) causes table rebuild which is not acceptable for many environments. It is possible to hack this around though I would not like to do this as a standard production practice. It is also worth to note ENUM [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Walter Heck</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-315611</link>
		<dc:creator>Walter Heck</dc:creator>
		<pubDate>Fri, 20 Jun 2008 23:06:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-315611</guid>
		<description>Does anyone know how to find out which commands will lead to a table rebuild? 
More specifically: how do I add comments to tables and columns without rebuilding them?</description>
		<content:encoded><![CDATA[<p>Does anyone know how to find out which commands will lead to a table rebuild?<br />
More specifically: how do I add comments to tables and columns without rebuilding them?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Trent Hornibrook</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-303693</link>
		<dc:creator>Trent Hornibrook</dc:creator>
		<pubDate>Thu, 22 May 2008 11:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-303693</guid>
		<description>Hi guys

I tried this though instead changed a signed INT to an unsigned INT. 

MySQL uses twos complement for negative ints and knowing that a table doesn’t contain any negative values, it was possible to just tell MySQL to use unsigned ints instead of signed without it needing to do anything.


On a test server, I ran::

(using world.sql)
mysql&gt; FLUSH TABLE WITH READ LOCK;
mysql&gt; ALTER TABLE City ENGINE=InnoDB;
mysql&gt; CREATE TABLE Citytmp LIKE City;
mysql&gt; ALTER TABLE Citytmp MODIFY ID INT UNSIGNED NOT NULL AUTO_INCREMENT;

# cp /var/lib/mysql/world/Citytmp.frm /var/lib/mysql/world/City.frm

mysql&gt; UNLOCK TABLES;



I then did it on a customers box that had 2^31 rows in Innodb with a primary key of signed int which was the initial problem. it worked great!</description>
		<content:encoded><![CDATA[<p>Hi guys</p>
<p>I tried this though instead changed a signed INT to an unsigned INT. </p>
<p>MySQL uses twos complement for negative ints and knowing that a table doesn’t contain any negative values, it was possible to just tell MySQL to use unsigned ints instead of signed without it needing to do anything.</p>
<p>On a test server, I ran::</p>
<p>(using world.sql)<br />
mysql&gt; FLUSH TABLE WITH READ LOCK;<br />
mysql&gt; ALTER TABLE City ENGINE=InnoDB;<br />
mysql&gt; CREATE TABLE Citytmp LIKE City;<br />
mysql&gt; ALTER TABLE Citytmp MODIFY ID INT UNSIGNED NOT NULL AUTO_INCREMENT;</p>
<p># cp /var/lib/mysql/world/Citytmp.frm /var/lib/mysql/world/City.frm</p>
<p>mysql&gt; UNLOCK TABLES;</p>
<p>I then did it on a customers box that had 2^31 rows in Innodb with a primary key of signed int which was the initial problem. it worked great!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Using MMM to ALTER huge tables &#124; MySQL Performance Blog</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-258509</link>
		<dc:creator>Using MMM to ALTER huge tables &#124; MySQL Performance Blog</dc:creator>
		<pubDate>Thu, 27 Mar 2008 20:42:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-258509</guid>
		<description>[...] months ago, I wrote about a faster way to do certain table modifications online. It works well when all you want is to remove auto_increment or change ENUM values. When it comes [...]</description>
		<content:encoded><![CDATA[<p>[...] months ago, I wrote about a faster way to do certain table modifications online. It works well when all you want is to remove auto_increment or change ENUM values. When it comes [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Blasgen</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-245241</link>
		<dc:creator>Nicholas Blasgen</dc:creator>
		<pubDate>Thu, 21 Feb 2008 08:37:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-245241</guid>
		<description>Now if there was just some way for me to update the COMMENT field of a column without defining everything else and rebuilding the table.

ALTER TABLE accounts ALTER COLUMN cWork SET COMMENT &#039;Foo&#039;;

But the current structure is more like:

ALTER TABLE accounts ALTER COLUMN cWork cWork BIGINT(11) UNSIGNED NOT NULL COMMENT &#039;Foo&#039;;

And changing all that is just silly for something as minor as a comment change.</description>
		<content:encoded><![CDATA[<p>Now if there was just some way for me to update the COMMENT field of a column without defining everything else and rebuilding the table.</p>
<p>ALTER TABLE accounts ALTER COLUMN cWork SET COMMENT &#8216;Foo&#8217;;</p>
<p>But the current structure is more like:</p>
<p>ALTER TABLE accounts ALTER COLUMN cWork cWork BIGINT(11) UNSIGNED NOT NULL COMMENT &#8216;Foo&#8217;;</p>
<p>And changing all that is just silly for something as minor as a comment change.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregert Johnson</title>
		<link>http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/comment-page-1/#comment-239031</link>
		<dc:creator>Gregert Johnson</dc:creator>
		<pubDate>Mon, 04 Feb 2008 20:06:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/10/29/hacking-to-make-alter-table-online-for-certain-changes/#comment-239031</guid>
		<description>Re: &quot;15. Travis&quot; - For MyISAM tables, you should see files created in the MySQL data directory with names something like #sqlnnn.frm, #sqlnnn.MYD, #sqlnnn.MYI, which are the temporary files being created to eventually replace your actual table (nnn is a sequence number).  The .MYD file (data file) is written first, and you can monitor the change in its size - it will probably end up being somewhat larger than the original .MYD file.  Next the .MYI file is built, and you can monitor its size as it&#039;s written, too.  If there had been no deletes or updates to the original index, then the final size of #sqlnnn.MYI will probably be exactly the same as the original .MYI, so you&#039;ll be able to judge how rapidly the rebuild is progressing.</description>
		<content:encoded><![CDATA[<p>Re: &#8220;15. Travis&#8221; &#8211; For MyISAM tables, you should see files created in the MySQL data directory with names something like #sqlnnn.frm, #sqlnnn.MYD, #sqlnnn.MYI, which are the temporary files being created to eventually replace your actual table (nnn is a sequence number).  The .MYD file (data file) is written first, and you can monitor the change in its size &#8211; it will probably end up being somewhat larger than the original .MYD file.  Next the .MYI file is built, and you can monitor its size as it&#8217;s written, too.  If there had been no deletes or updates to the original index, then the final size of #sqlnnn.MYI will probably be exactly the same as the original .MYI, so you&#8217;ll be able to judge how rapidly the rebuild is progressing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
