<?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: Clone a table in MySQL without killing your server</title>
	<atom:link href="http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/</link>
	<description>Made with only the finest 1's and 0's</description>
	<lastBuildDate>Wed, 10 Mar 2010 20:02:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bill</title>
		<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/comment-page-1/#comment-36559</link>
		<dc:creator>Bill</dc:creator>
		<pubDate>Wed, 10 Mar 2010 20:02:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=365#comment-36559</guid>
		<description>I recently looked this article back up because I am a new company and needed this script again.  Great script with one exception.  The limit command starts to deteriorate in performance when you have larger tables (at least with MyISAM which we were using).  I had a database with 40M rows and after a million or two performance came to a crawl.   I don&#039;t have access to the script anymore, but at the time I rewrote it to use the Primary key column instead.  You do run into dead spots if they table has had deletes but for the most part it is quick.  Be sure to order on the primary key if you use that method.</description>
		<content:encoded><![CDATA[<p>I recently looked this article back up because I am a new company and needed this script again.  Great script with one exception.  The limit command starts to deteriorate in performance when you have larger tables (at least with MyISAM which we were using).  I had a database with 40M rows and after a million or two performance came to a crawl.   I don&#8217;t have access to the script anymore, but at the time I rewrote it to use the Primary key column instead.  You do run into dead spots if they table has had deletes but for the most part it is quick.  Be sure to order on the primary key if you use that method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/comment-page-1/#comment-4336</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Mon, 13 Oct 2008 12:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=365#comment-4336</guid>
		<description>@Skip

Yeah but the &quot;CREATE TABLE new LIKE old;&quot; method will create the new table with the same indexes as the old table. The idea in this case seems to be to create the table without any indexes. &quot;CREATE TABLE new AS SELECT * from old;&quot; will create new with the same schema as old, but without any indexes.</description>
		<content:encoded><![CDATA[<p>@Skip</p>
<p>Yeah but the &#8220;CREATE TABLE new LIKE old;&#8221; method will create the new table with the same indexes as the old table. The idea in this case seems to be to create the table without any indexes. &#8220;CREATE TABLE new AS SELECT * from old;&#8221; will create new with the same schema as old, but without any indexes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Seun Osewa</title>
		<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/comment-page-1/#comment-4320</link>
		<dc:creator>Seun Osewa</dc:creator>
		<pubDate>Mon, 13 Oct 2008 01:55:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=365#comment-4320</guid>
		<description>Methinks the best way to deal with unused indexes is to just drop them.  It doesn&#039;t take any time at all because indexes are stored separately.</description>
		<content:encoded><![CDATA[<p>Methinks the best way to deal with unused indexes is to just drop them.  It doesn&#8217;t take any time at all because indexes are stored separately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shantanu Oak</title>
		<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/comment-page-1/#comment-4302</link>
		<dc:creator>Shantanu Oak</dc:creator>
		<pubDate>Sun, 12 Oct 2008 12:47:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=365#comment-4302</guid>
		<description>For medium sized tables, use outfile. Test case...
mysql&gt; SELECT * INTO OUTFILE &#039;shantanu.txt&#039; FIELDS TERMINATED BY &#039;&#124;&#039; OPTIONALLY ENCLOSED BY &#039;&quot;&#039; LINES TERMINATED BY &#039;\n&#039; FROM bad;
Query OK, 2681793 rows affected (59.72 sec)

mysql&gt; alter table good disable keys;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; LOAD DATA INFILE &#039;shantanu.txt&#039; INTO TABLE good 
FIELDS TERMINATED BY &#039;&#124;&#039; OPTIONALLY ENCLOSED BY &#039;&quot;&#039;;
Query OK, 2681793 rows affected (3 min 49.91 sec)
Records: 2681793  Deleted: 0  Skipped: 0  Warnings: 0

mysql&gt; alter table good enable  keys;
Query OK, 0 rows affected (11 min 1.68 sec)

You can use Lock on source table so that writes will temporarily halt but can continue once the data is out.
LOCK TABLES bad WRITE;
UNLOCK TABLES;</description>
		<content:encoded><![CDATA[<p>For medium sized tables, use outfile. Test case&#8230;<br />
mysql&gt; SELECT * INTO OUTFILE &#8217;shantanu.txt&#8217; FIELDS TERMINATED BY &#8216;|&#8217; OPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216; LINES TERMINATED BY &#8216;\n&#8217; FROM bad;<br />
Query OK, 2681793 rows affected (59.72 sec)</p>
<p>mysql&gt; alter table good disable keys;<br />
Query OK, 0 rows affected (0.00 sec)</p>
<p>mysql&gt; LOAD DATA INFILE &#8217;shantanu.txt&#8217; INTO TABLE good<br />
FIELDS TERMINATED BY &#8216;|&#8217; OPTIONALLY ENCLOSED BY &#8216;&#8221;&#8216;;<br />
Query OK, 2681793 rows affected (3 min 49.91 sec)<br />
Records: 2681793  Deleted: 0  Skipped: 0  Warnings: 0</p>
<p>mysql&gt; alter table good enable  keys;<br />
Query OK, 0 rows affected (11 min 1.68 sec)</p>
<p>You can use Lock on source table so that writes will temporarily halt but can continue once the data is out.<br />
LOCK TABLES bad WRITE;<br />
UNLOCK TABLES;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Skip</title>
		<link>http://www.protocolostomy.com/2008/10/09/clone-a-table-in-mysql-without-killing-your-server/comment-page-1/#comment-4249</link>
		<dc:creator>Skip</dc:creator>
		<pubDate>Fri, 10 Oct 2008 16:41:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.protocolostomy.com/?p=365#comment-4249</guid>
		<description>An even simpler way to create the new table would be:

CREATE TABLE new LIKE old;</description>
		<content:encoded><![CDATA[<p>An even simpler way to create the new table would be:</p>
<p>CREATE TABLE new LIKE old;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
