<?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: Don’t Alter Table. Do Copy and Rename</title> <atom:link href="http://www.rndblog.com/don%E2%80%99t-alter-table-do-copy-and-rename/feed/" rel="self" type="application/rss+xml" /><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/</link> <description>Programming, Researching and Developing practice</description> <lastBuildDate>Thu, 18 Apr 2013 08:30:04 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.5.1</generator> <item><title>By: Ilan Hazan</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-647</link> <dc:creator>Ilan Hazan</dc:creator> <pubDate>Thu, 10 Nov 2011 09:20:34 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-647</guid> <description><![CDATA[In most cases, ALTER TABLE makes a temporary copy of the original table. MySQL waits for other operations that are modifying the table, then proceeds. It incorporates the alteration into the copy, deletes the original table, and renames the new one. While ALTER TABLE is executing, the original table is readable by other sessions.
HOWEVER, If you use ALTER TABLE tbl_name RENAME TO new_tbl_name without any other options, MySQL simply renames any files that correspond to the table tbl_name without making a copy.
That is mean that both the &quot;ALTER ... RENAME&quot; and the &quot;RENAME TABLE&quot; statement are equivalent except one thing:
You cannot use RENAME to rename a TEMPORARY table. However, you can use ALTER TABLE instead:
mysql&gt; ALTER TABLE orig_name RENAME new_name;]]></description> <content:encoded><![CDATA[<p>In most cases, ALTER TABLE makes a temporary copy of the original table. MySQL waits for other operations that are modifying the table, then proceeds. It incorporates the alteration into the copy, deletes the original table, and renames the new one. While ALTER TABLE is executing, the original table is readable by other sessions.</p><p>HOWEVER, If you use ALTER TABLE tbl_name RENAME TO new_tbl_name without any other options, MySQL simply renames any files that correspond to the table tbl_name without making a copy.</p><p>That is mean that both the &#8220;ALTER &#8230; RENAME&#8221; and the &#8220;RENAME TABLE&#8221; statement are equivalent except one thing:<br
/> You cannot use RENAME to rename a TEMPORARY table. However, you can use ALTER TABLE instead:<br
/> mysql&gt; ALTER TABLE orig_name RENAME new_name;</p> ]]></content:encoded> </item> <item><title>By: xyz</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-646</link> <dc:creator>xyz</dc:creator> <pubDate>Thu, 10 Nov 2011 06:44:47 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-646</guid> <description><![CDATA[What is the benefit if we change the table name using alter command]]></description> <content:encoded><![CDATA[<p>What is the benefit if we change the table name using alter command</p> ]]></content:encoded> </item> <item><title>By: Shlomi Noach</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-164</link> <dc:creator>Shlomi Noach</dc:creator> <pubDate>Thu, 03 Mar 2011 07:47:27 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-164</guid> <description><![CDATA[Well, there&#039;s less locks on the table. It would be possible to write to the table during that time. Although, this also means you may have inconsistent copy, in case someone was DELETEing or UPDATEing rows already accessed.
By the way, oak-online-alter-table solves that as well.]]></description> <content:encoded><![CDATA[<p>Well, there&#8217;s less locks on the table. It would be possible to write to the table during that time. Although, this also means you may have inconsistent copy, in case someone was DELETEing or UPDATEing rows already accessed.<br
/> By the way, oak-online-alter-table solves that as well.</p> ]]></content:encoded> </item> <item><title>By: admin</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-122</link> <dc:creator>admin</dc:creator> <pubDate>Wed, 02 Mar 2011 07:57:33 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-122</guid> <description><![CDATA[I am sorry for not mentioning (in the beginning) that the Copy and Rename approach is applied only for MyISAM tables.]]></description> <content:encoded><![CDATA[<p>I am sorry for not mentioning (in the beginning) that the Copy and Rename approach is applied only for MyISAM tables.</p> ]]></content:encoded> </item> <item><title>By: admin</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-121</link> <dc:creator>admin</dc:creator> <pubDate>Wed, 02 Mar 2011 07:54:40 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-121</guid> <description><![CDATA[MyISAM is great for sites you have lots of reads and relative small writes.
I assume, that in a case of a need to change the schema, you must turn your site to work in &quot;read only&quot; mode. This means no writes in the maintenance period.]]></description> <content:encoded><![CDATA[<p>MyISAM is great for sites you have lots of reads and relative small writes.<br
/> I assume, that in a case of a need to change the schema, you must turn your site to work in &#8220;read only&#8221; mode. This means no writes in the maintenance period.</p> ]]></content:encoded> </item> <item><title>By: admin</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-120</link> <dc:creator>admin</dc:creator> <pubDate>Wed, 02 Mar 2011 07:51:06 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-120</guid> <description><![CDATA[Cameron,
Thank you for this great tip.]]></description> <content:encoded><![CDATA[<p>Cameron,<br
/> Thank you for this great tip.</p> ]]></content:encoded> </item> <item><title>By: admin</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-119</link> <dc:creator>admin</dc:creator> <pubDate>Wed, 02 Mar 2011 07:47:43 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-119</guid> <description><![CDATA[Hi Shlomi,
You are right that the Copy and Rename approach is good only for MyISAM tables.
In huge MyISAM tables the Copy and Rename approach is performing much better than the ALTER TABLE.
I cant see any improvement by breaking the INSERT.. SELECT into smaller chunks.]]></description> <content:encoded><![CDATA[<p>Hi Shlomi,<br
/> You are right that the Copy and Rename approach is good only for MyISAM tables.<br
/> In huge MyISAM tables the Copy and Rename approach is performing much better than the ALTER TABLE.<br
/> I cant see any improvement by breaking the INSERT.. SELECT into smaller chunks.</p> ]]></content:encoded> </item> <item><title>By: danielj</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-81</link> <dc:creator>danielj</dc:creator> <pubDate>Tue, 01 Mar 2011 14:05:04 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-81</guid> <description><![CDATA[erm... who uses MyISAM these days? :)
And how would you deal with write requests?]]></description> <content:encoded><![CDATA[<p>erm&#8230; who uses MyISAM these days? <img
src='http://www.rndblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>And how would you deal with write requests?</p> ]]></content:encoded> </item> <item><title>By: admin</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-74</link> <dc:creator>admin</dc:creator> <pubDate>Tue, 01 Mar 2011 12:45:36 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-74</guid> <description><![CDATA[I assume that in this maintenance period, the site will be in &quot;Read-Only&quot; mode. That is mean no write request to the table.
In the &quot;Copy and Rename&quot; approach, the site will still serve read request while in the &quot;ALTER TABLE&quot; approach the read requests will be blocked until MySQL will done altering the table.]]></description> <content:encoded><![CDATA[<p>I assume that in this maintenance period, the site will be in &#8220;Read-Only&#8221; mode. That is mean no write request to the table.<br
/> In the &#8220;Copy and Rename&#8221; approach, the site will still serve read request while in the &#8220;ALTER TABLE&#8221; approach the read requests will be blocked until MySQL will done altering the table.</p> ]]></content:encoded> </item> <item><title>By: Shlomi Noach</title><link>http://www.rndblog.com/don%e2%80%99t-alter-table-do-copy-and-rename/#comment-70</link> <dc:creator>Shlomi Noach</dc:creator> <pubDate>Tue, 01 Mar 2011 11:04:57 +0000</pubDate> <guid
isPermaLink="false">http://www.rndblog.com/?p=78#comment-70</guid> <description><![CDATA[Hi,
You should first approve my comment for it to appear on your post, before responding to it. No one can see it but myself.
The copy+rename may perform much better than ALTER, but I suggest they perform much worse than if you did the copy in smaller chunks.
But the truth is I never benchmarked on huge MyISAM tables.]]></description> <content:encoded><![CDATA[<p>Hi,</p><p>You should first approve my comment for it to appear on your post, before responding to it. No one can see it but myself.</p><p>The copy+rename may perform much better than ALTER, but I suggest they perform much worse than if you did the copy in smaller chunks.<br
/> But the truth is I never benchmarked on huge MyISAM tables.</p> ]]></content:encoded> </item> </channel> </rss>