<?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>Data-Diggers.com &#187; innodb vs myisam</title>
	<atom:link href="http://www.data-diggers.com/index.php/tag/innodb-vs-myisam/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.data-diggers.com</link>
	<description>Zen Cart Optimization, Performance and A/B Split Testing Modules for Zen Cart</description>
	<lastBuildDate>Mon, 24 May 2010 18:56:27 +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 vs MyISAM performance in Zen Cart. Which is better?</title>
		<link>http://www.data-diggers.com/index.php/2009/01/innodb-vs-myisam-performance-in-zen-cart-which-is-better/</link>
		<comments>http://www.data-diggers.com/index.php/2009/01/innodb-vs-myisam-performance-in-zen-cart-which-is-better/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 13:36:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[innodb vs myisam]]></category>
		<category><![CDATA[Zen Cart]]></category>

		<guid isPermaLink="false">http://www.data-diggers.eu/?p=31</guid>
		<description><![CDATA[
			
				
			
		
Zen Cart uses MyISAM tables to store data, but MySQL offers other storage engines too. Is MyISAM the best choice? Is it the fastest one? These questions will be answered.. right now: No, it isn&#8217;t (at least not always). Read below to find out more.
Performance test
Note: In test We used MySQL 5.0.41. Results can vary depending [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.data-diggers.com%2Findex.php%2F2009%2F01%2Finnodb-vs-myisam-performance-in-zen-cart-which-is-better%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.data-diggers.com%2Findex.php%2F2009%2F01%2Finnodb-vs-myisam-performance-in-zen-cart-which-is-better%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Zen Cart uses MyISAM tables to store data, but MySQL offers other storage engines too. Is MyISAM the best choice? Is it the fastest one? These questions will be answered.. right now: No, it isn&#8217;t (at least not always). Read below to find out more.</p>
<h2 style="text-align: justify;"><strong>Performance test</strong></h2>
<p style="text-align: justify;"><strong>Note</strong>: <em>In test We used MySQL 5.0.41. Results can vary depending on MySQL version You use.</em></p>
<p style="text-align: justify;">Let&#8217;s find out which of the two is faster. To do this We&#8217;ll need to test their performance. We created Java application which executes typical SELECT queries against Zen Cart demo store database and measures query performance. Here are some of those queries:</p>
<p style="text-align: justify;">SELECT queries</p>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> SQL_NO_CACHE count<span class="br0">&#40;</span><span class="sy0">*</span><span class="br0">&#41;</span> <span class="kw1">AS</span> total<br />
<span class="kw1">FROM</span> products p<span class="sy0">,</span> products_to_categories p2c<br />
<span class="kw1">WHERE</span> p<span class="sy0">.</span>products_id <span class="sy0">=</span> p2c<span class="sy0">.</span>products_id<br />
<span class="kw1">AND</span> p<span class="sy0">.</span>products_status <span class="sy0">=</span> <span class="st0">&#8216;1&#8242;</span><br />
<span class="kw1">AND</span> p2c<span class="sy0">.</span>categories_id <span class="sy0">=</span> <span class="st0">&#8216;22&#8242;</span></div>
</div>
</div>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> SQL_NO_CACHE products_type<br />
<span class="kw1">FROM</span> products<br />
<span class="kw1">WHERE</span> products_id <span class="sy0">=</span> <span class="st0">&#8216;12&#8242;</span></div>
</div>
</div>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> SQL_NO_CACHE <span class="kw1">DISTINCT</span> p<span class="sy0">.</span>products_id<span class="sy0">,</span> p<span class="sy0">.</span>products_image<span class="sy0">,</span> pd<span class="sy0">.</span>products_name<span class="sy0">,</span> p<span class="sy0">.</span>master_categories_id<br />
<span class="kw1">FROM</span> <span class="br0">&#40;</span>products p<br />
<span class="kw1">LEFT</span> <span class="kw1">JOIN</span> featured f <span class="kw1">ON</span> p<span class="sy0">.</span>products_id <span class="sy0">=</span> f<span class="sy0">.</span>products_id<br />
<span class="kw1">LEFT</span> <span class="kw1">JOIN</span> products_description pd <span class="kw1">ON</span> p<span class="sy0">.</span>products_id <span class="sy0">=</span> pd<span class="sy0">.</span>products_id <span class="br0">&#41;</span><br />
<span class="kw1">WHERE</span> p<span class="sy0">.</span>products_id <span class="sy0">=</span> f<span class="sy0">.</span>products_id<br />
<span class="kw1">AND</span> p<span class="sy0">.</span>products_id <span class="sy0">=</span> pd<span class="sy0">.</span>products_id<br />
<span class="kw1">AND</span> p<span class="sy0">.</span>products_status <span class="sy0">=</span> 1 <span class="kw1">AND</span> f<span class="sy0">.</span><span class="kw1">STATUS</span> <span class="sy0">=</span> 1<br />
<span class="kw1">AND</span> pd<span class="sy0">.</span>language_id <span class="sy0">=</span> <span class="st0">&#8216;1&#8242;</span></div>
</div>
</div>
<p style="text-align: justify;">Note that We added <strong>SQL_NO_CACHE</strong> to prevent MySQL from caching query results.</p>
<p style="text-align: justify;">Now, it&#8217;s important to simulate many customers wandering around Zen Cart store. Therefore We used 10 threads to send queries to database.</p>
<p style="text-align: justify;">InnoDB managed to perform <strong>1186 </strong>queries per second on average, where MyISAM executed only <strong>958 </strong>queries per second on average. <strong>InnoDB was faster by almost 25%!</strong></p>
<h2 style="text-align: justify;"><strong>Locking strategy</strong></h2>
<p style="text-align: justify;">Very important feature (from performance perspective) is that InnoDB uses per row locking, where MyISAM uses table locking. What does it mean? We&#8217;ll clarify it with example.</p>
<p style="text-align: justify;">Let&#8217;s assume that We&#8217;re executing following update against products table:</p>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">UPDATE</span> products<br />
<span class="kw1">SET</span> products_ordered <span class="sy0">=</span> products_ordered <span class="sy0">+</span> 1<br />
<span class="kw1">WHERE</span> products_id <span class="sy0">=</span> <span class="nu0">12</span></div>
</div>
</div>
<p style="text-align: justify;">and other thread (other http request from other customer) is executing at the same time following query:</p>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">SELECT</span> products_type<br />
<span class="kw1">FROM</span> products<br />
<span class="kw1">WHERE</span> products_id <span class="sy0">=</span> <span class="st0">&#8216;17&#8242;</span></div>
</div>
</div>
<p style="text-align: justify;">Because MyISAM uses table locking when updates are made to tables, it will prevent execution of other SELECT queries until update statement finishes, even if those queries don&#8217;t look at updated rows.</p>
<p style="text-align: justify;">InnoDB on the other hand will lock only row with products_id field set to 17, allowing concurrent execution of SELECT queries (unless those queries are asking for data from updated row).</p>
<p style="text-align: justify;">It does not give much performance boost when Your store has low traffic, but when it&#8217;ll get more popular (hopefully<img src="http://www.data-diggers.com/sites/all/modules/fckeditor/fckeditor/editor/images/smiley/msn/wink_smile.gif" alt="" />) and You&#8217;ll have ten thousands visits per day it&#8217;ll make a difference ( the more traffic You&#8217;ll get the bigger the difference should be).</p>
<h2 style="text-align: justify;"><strong>How to convert MyISAM table to InnoDB table</strong></h2>
<p style="text-align: justify;">To convert any table example to InnoDB execute following SQL code:</p>
<div style="text-align: justify;">
<div class="codesnip-container" >
<div class="sql codesnip" style="font-family:monospace;"><span class="kw1">ALTER</span> <span class="kw1">TABLE</span> example ENGINE <span class="sy0">=</span> InnoDB</div>
</div>
</div>
<p style="text-align: justify;">Unfortunately Zen Cart database contains about 80 tables, so changing each of them by hand would be inconvenient. Also, one may want to change back to MyISAM for some reason, and it would have to repeat whole process again. To address that problem We created simple Zen Cart contribution that automates conversion from MyISAM to InnoDB. You can download it here:</p>
<p style="text-align: center;"><a href="http://www.data-diggers.com/contribs/change-storage-engine/downloads/change_storage_engine_current.zip">Download Change Storage Engine</a></p>
<p style="text-align: justify;">Installation is very easy, just copy unzipped folder to Your store directory. This contribution does not overwrite any Zen Cart files, so You don&#8217;t have to worry about that. To change <strong>all</strong> tables in Your database from MyISAM/InnoDB to InnoDB/MyISAM go to <em>Tools-&gt;Change Storage Engine</em> and click &#8216;Change&#8217;. That&#8217;s it!</p>
<h2 style="text-align: justify;"><strong>Summary</strong></h2>
<p style="text-align: justify;">InnoDB is faster then MyISAM engine, it also scales better. But before You change all Your tables to InnoDB make sure to (as always) make backup of Your database. Also, after changing tables to InnoDB check if Your store runs faster as MySQL performance differs from version to version.</p>
<h2 style="text-align: justify;"><strong>Updates</strong></h2>
<p style="text-align: justify;">Version 1.1 of Change Storage Engine is available (use link above, it always points to newest version). It&#8217;ll omit MyISAM tables with FULLTEXT indexes (InnoDB does not support FULLTEXT indexes).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.data-diggers.com/index.php/2009/01/innodb-vs-myisam-performance-in-zen-cart-which-is-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
