<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lamp, scalability, opensource &#187; per table tablespaces</title>
	<atom:link href="http://lamp.mayavi.info/index.php/tag/per-table-tablespaces/feed" rel="self" type="application/rss+xml" />
	<link>http://lamp.mayavi.info</link>
	<description></description>
	<lastBuildDate>Mon, 01 Jun 2009 05:57:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>InnoDB per-table tablespaces &#8211; file for each innodb table</title>
		<link>http://lamp.mayavi.info/index.php/databases/innodb-per-table-tablespaces-file-for-each-innodb-table.html</link>
		<comments>http://lamp.mayavi.info/index.php/databases/innodb-per-table-tablespaces-file-for-each-innodb-table.html#comments</comments>
		<pubDate>Wed, 06 May 2009 20:40:46 +0000</pubDate>
		<dc:creator>Ranjeet Walunj</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[database fragmentation]]></category>
		<category><![CDATA[ibdata]]></category>
		<category><![CDATA[ibdata1]]></category>
		<category><![CDATA[innodb]]></category>
		<category><![CDATA[innodb_file_per_table]]></category>
		<category><![CDATA[mysql engine]]></category>
		<category><![CDATA[per table tablespaces]]></category>
		<category><![CDATA[regain harddrive space used by ibdata1]]></category>
		<category><![CDATA[shrink]]></category>

		<guid isPermaLink="false">http://lamp.mayavi.info/?p=12</guid>
		<description><![CDATA[
		
		
		
		
		
		
		
		Lot has been discussed over the usefulness and power of various mysql engines. (Viz. MyISAM or InnoDB or Archive)
In basic format, MyISAM is faster in SELECT operations and running `fulltext indexes/searches`.
Whereas InnoDB has transaction support and ROW-Level locking which helps in database locking issue.
MyISAM engine stores data and indexes for each table in separate files [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.4 Start--><div style="float: right; width: 42px; padding-right: 90px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		reddit_url = "http://lamp.mayavi.info/index.php/databases/innodb-per-table-tablespaces-file-for-each-innodb-table.html";
		reddit_title = "InnoDB per-table tablespaces &#8211; file for each innodb table";
		//-->
		</script>
		<script type="text/javascript" src="http://www.reddit.com/button.js?t=1"></script></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://lamp.mayavi.info/index.php/databases/innodb-per-table-tablespaces-file-for-each-innodb-table.html";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "InnoDB per-table tablespaces &#8211; file for each innodb table";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.4 End--><p>Lot has been discussed over the usefulness and power of various mysql engines. (Viz. MyISAM or InnoDB or Archive)</p>
<p>In basic format, MyISAM is faster in SELECT operations and running `fulltext indexes/searches`.</p>
<p>Whereas InnoDB has transaction support and ROW-Level locking which helps in database locking issue.</p>
<p>MyISAM engine stores data and indexes for each table in separate files as follows :<br />
 MYI = index file, MYD = data file, FRM = format (schema) file</p>
<p>Whereas default installation of InnoDB engine stores most of the information in single file called ibdata1. (usually /var/lib/mysql/ibdata1 )</p>
<p>This default behaviour of InnoDB engine has few drawbacks: (Its a well known fact that InnoDB needs good tuning to give much solid performance.)<br />
 1) Single large file<br />
 2) Even if the tables/data is deleted from InnoDB tables, the size taken by ibdata1 does not shrink  (eventually space crunch on server)<br />
 3) Fragmentation</p>
<p>To avoid above situations, it is always wise to add per-table tablespace option in InnoDB config parameters in /etc/my.cnf<br />
 Add following parameter to conf file :</p>
<blockquote><p style="padding-left: 90px;">[mysqld]<br />
 innodb_file_per_table</p>
</blockquote>
<p><a title="MySQL referrence -- Using Per-Table Tablespaces" href="http://dev.mysql.com/doc/refman/5.0/en/multiple-tablespaces.html" target="_blank">Read here</a> about the innodb_file_per_table config parameter.</p>
<p>What this parameter will ensure that all new tables (Please note: Only new InnoDB tables) will have individual file for data instead of single large file for all innodb tables.</p>
<p>Now real question is what will happen to existing tables which are already InnoDB/MyISAM tables.</p>
<p>Applying anyone of the following method will ensure conversion of existing InnoDB tables in using multiple tablespaces.</p>
<p>1) Export all databases, delete ibdata1 and import everything back<br />
 This is sure way of converting everything to per-table tablespaces along with fresh ibdata1 file</p>
<p>2) Export only InnoDB tables, drop them, delete ibdata1 and import InnoDB tables back into respective databases<br />
 If there are lots of databases and dumping all DB is not an option then this step can be performed.<br />
 Note: Please ensure backup at every stage</p>
<p>3)     run  following command in your shell</p>
<p style="padding-left: 60px;">mysqlcheck  &#8211;optimize &#8211;all-databases</p>
<p>4) Convert all InnoDB tables to MyISAM using ALTER TABLE command<br />
 for each InnoDB table run following command at mysql prompt</p>
<blockquote><p style="padding-left: 60px;">mysql&gt;ALTER TABLE tablename ENGINE=InnoDB;</p>
</blockquote>
<p>However STEP 3 and 4 does not shrink the exising size of ibdata1 file.  To regain the space used earlier by ibdata1, please use step1 or step2</p>
<p>And most important after every mysql installation pls add the &#8216;innodb_file_per_table&#8217; parameter in your /etc/my.cnf</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://lamp.mayavi.info/index.php/databases/innodb-per-table-tablespaces-file-for-each-innodb-table.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
