<?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>Weez.com &#187; optimize</title>
	<atom:link href="http://www.weez.com/tag/optimize/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weez.com</link>
	<description>Solving everyday practical LAMP problems... one at a time</description>
	<lastBuildDate>Sat, 11 Feb 2012 03:24:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Thinking about running OPTIMIZE on your Innodb Table ? Stop!</title>
		<link>http://www.weez.com/2010/12/thinking-about-running-optimize-on-your-innodb-table-stop/</link>
		<comments>http://www.weez.com/2010/12/thinking-about-running-optimize-on-your-innodb-table-stop/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 21:46:03 +0000</pubDate>
		<dc:creator>Abidoon</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[Running]]></category>
		<category><![CDATA[stop]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[thinking]]></category>

		<guid isPermaLink="false">http://www.weez.com/2010/12/thinking-about-running-optimize-on-your-innodb-table-stop/</guid>
		<description><![CDATA[Innodb/XtraDB tables do benefit from being reorganized often. You can get data physically laid out in primary key order as well as get better feel for primary key and index pages and so using less space, it is just OPTIMIZE TABLE might not be best way to do it. If you&#8217;re running Innodb Plugin on [...]]]></description>
			<content:encoded><![CDATA[<p>Innodb/XtraDB tables do benefit from being reorganized often.   You can get data physically laid out in primary key order as well as get better feel for primary key and index pages and so using less space,<br />
it is just OPTIMIZE TABLE might not be best way to do it. </p>
<p>If you&#8217;re running Innodb Plugin on Percona Server with XtraDB you get benefit of a great new feature &#8211; ability to build indexes by sort instead of via insertion.  This process can be a lot faster, especially for large indexes which would get inserts in very random order, such as indexes on UUID column or something similar. It also produces a lot better fill factor.  The problem is&#8230;. OPTIMIZE TABLE for Innodb tables does not get advantage of it for whatever reason.   </p>
<p>Lets take a look at little benchmark I done by running OPTIMIZE for a second time on a table which is some 10 times larger than amount of memory I allocated for buffer pool:</p>
<div class="igBar"><span id="lsql-2"><a href="#" onclick="javascript:showPlainTxt('sql-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span></p>
<div id="sql-2">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`a`</span> <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`id`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`c`</span> char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">64</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`c`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`c`</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=InnoDB <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>=<span style="color: #cc66cc;color:#800000;">12582913</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysql&gt; <span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> a <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> id <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;color:#800000;">10</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| id | c&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">1</span> | 813cf02d7d65de2639014dd1fb574d4c481ecac7 |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">2</span> | 62960f5d5d50651e5a5983dacaedfa9a73a9ee87 |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">3</span> | cea33998792ffe28b16b9272b950102a9633439f |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">4</span> | 8346a7afa0a0791693338d96a07a944874340a1c |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">5</span> | b00faaa432f507a0d16d2940ca8ec36699f141c8 |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">6</span> | 8e00926cf6c9b13dc8e0664a744b7116c5c61036 |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">7</span> | f151fe34b66fd4d28521d5e7ccb68b0d5d81f21b |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">8</span> | 7fceb5afa200a27b81cab45f94903ce04d6f24db |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color: #cc66cc;color:#800000;">9</span> | 0397562dc35b5242842d68de424aa9f0b409d60f |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| <span style="color: #cc66cc;color:#800000;">10</span> | af8efbaef7010a1a3bfdff6609e5c233c897e1d5 |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc66cc;color:#800000;">10</span> rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>.<span style="color: #cc66cc;color:#800000;">04</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># This is just random SHA(1) hashes</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysql&gt; <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> a;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| <span style="color: #993333; font-weight: bold;">TABLE</span>&nbsp; | Op&nbsp; &nbsp; &nbsp; &nbsp;| Msg_type | Msg_text&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| test.a | <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> | note&nbsp; &nbsp; &nbsp;| <span style="color: #993333; font-weight: bold;">TABLE</span> does <span style="color: #993333; font-weight: bold;">NOT</span> support <span style="color: #993333; font-weight: bold;">OPTIMIZE</span>, doing recreate + analyze instead |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| test.a | <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> | <span style="color: #993333; font-weight: bold;">STATUS</span>&nbsp; &nbsp;| OK&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc66cc;color:#800000;">2</span> rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</span> hours <span style="color: #cc66cc;color:#800000;">3</span> min <span style="color: #cc66cc;color:#800000;">35</span>.<span style="color: #cc66cc;color:#800000;">15</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysql&gt; <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> a <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">KEY</span> c;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Query OK, <span style="color: #cc66cc;color:#800000;">0</span> rows affected <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">0</span>.<span style="color: #cc66cc;color:#800000;">46</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Records: <span style="color: #cc66cc;color:#800000;">0</span>&nbsp; Duplicates: <span style="color: #cc66cc;color:#800000;">0</span>&nbsp; Warnings: <span style="color: #cc66cc;color:#800000;">0</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysql&gt; <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> a;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| <span style="color: #993333; font-weight: bold;">TABLE</span>&nbsp; | Op&nbsp; &nbsp; &nbsp; &nbsp;| Msg_type | Msg_text&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| test.a | <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> | note&nbsp; &nbsp; &nbsp;| <span style="color: #993333; font-weight: bold;">TABLE</span> does <span style="color: #993333; font-weight: bold;">NOT</span> support <span style="color: #993333; font-weight: bold;">OPTIMIZE</span>, doing recreate + analyze instead |</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| test.a | <span style="color: #993333; font-weight: bold;">OPTIMIZE</span> | <span style="color: #993333; font-weight: bold;">STATUS</span>&nbsp; &nbsp;| OK&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+<span style="color: #808080; font-style: italic;">&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #cc66cc;color:#800000;">2</span> rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">4</span> min <span style="color: #cc66cc;color:#800000;">5</span>.<span style="color: #cc66cc;color:#800000;">52</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mysql&gt; <span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> a <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color:#006600; font-weight:bold;">&#40;</span>c<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Query OK, <span style="color: #cc66cc;color:#800000;">0</span> rows affected <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">5</span> min <span style="color: #cc66cc;color:#800000;">51</span>.<span style="color: #cc66cc;color:#800000;">83</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Records: <span style="color: #cc66cc;color:#800000;">0</span>&nbsp; Duplicates: <span style="color: #cc66cc;color:#800000;">0</span>&nbsp; Warnings: <span style="color: #cc66cc;color:#800000;">0</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>That&#8217;s right !  Optimizing table straight away takes over 3 hours, while dropping  indexes besides primary key, optimizing table and adding them back takes about 10 minutes, which is close than <strong>20x speed difference</strong> and more compact index in the end.</p>
<p>So if you&#8217;re considering running OPTIMIZE on your tables consider using this trick, it is especially handy when you&#8217;re running it on the Slave where it is OK table is exposed without indexes for some time.<br />
Note though nothing stops you from using LOCK TABLES on Innodb table to ensure there is not ton of queries starting reading table with no indexes and bringing box down.</p>
<p>You can also use this trick for ALTER TABLE which requires table rebuild. Dropping all indexes;  doing ALTER and when adding them back can be a lot faster than straight ALTER TABLE.</p>
<p>P.S  I do not know why this was not done when support for creating index by sorting was implemented.  It looks very strange to me to have this feature implemented but majority of high level commands<br />
or tools (like mysqldump) do not get advantage of it and will use old slow method of building indexes by insertion. </p>
<hr noshade style="margin:0;height:1px" />
<p>Entry posted by peter |<br />
      <a href="http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/#comments">3 comments</a></p>
<p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/&amp;title=Thinking about running OPTIMIZE on your Innodb Table ?  Stop!" title="Bookmark this post on del.icio.us"><img src="http://www.mysqlperformanceblog.com/wp-content/themes/boxy-but-gold/images/delicious.png" alt="delicious" /></a> | <a href="http://digg.com/submit?phase=2&amp;url=http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/&amp;title=Thinking about running OPTIMIZE on your Innodb Table ?  Stop!" title="Digg this post on Digg.com"><img src="http://www.mysqlperformanceblog.com/wp-content/themes/boxy-but-gold/images/digg.png" alt="digg" /></a> | <a href="http://reddit.com/submit?url=http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/&amp;title=Thinking about running OPTIMIZE on your Innodb Table ?  Stop!" title="Submit this post on reddit.com"><img src="http://www.mysqlperformanceblog.com/wp-content/themes/boxy-but-gold/images/reddit.png" alt="reddit" /></a> | <a href="http://www.netscape.com/submit/?U=http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/&amp;T=Thinking about running OPTIMIZE on your Innodb Table ?  Stop!" title="Vote for this article on Netscape"><img src="http://www.mysqlperformanceblog.com/wp-content/themes/boxy-but-gold/images/netscape.gif" alt="netscape" /></a> | <a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/&amp;title=Thinking about running OPTIMIZE on your Innodb Table ?  Stop!" title="Add to Google Bookmarks"><img src="http://www.mysqlperformanceblog.com/wp-content/themes/boxy-but-gold/images/google.png" alt="Google Bookmarks" /></a></p>
<p>View full post on <a href="http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/">MySQL Performance Blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.weez.com/2010/12/thinking-about-running-optimize-on-your-innodb-table-stop/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SapientNitro Selects KENSHOO as Technology of Choice to Optimize Value of Search Engine Marketing for their Clients</title>
		<link>http://www.weez.com/2010/07/sapientnitro-selects-kenshoo-as-technology-of-choice-to-optimize-value-of-search-engine-marketing-for-their-clients/</link>
		<comments>http://www.weez.com/2010/07/sapientnitro-selects-kenshoo-as-technology-of-choice-to-optimize-value-of-search-engine-marketing-for-their-clients/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 02:18:05 +0000</pubDate>
		<dc:creator>Abidoon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Choice]]></category>
		<category><![CDATA[Clients]]></category>
		<category><![CDATA[Engine]]></category>
		<category><![CDATA[KENSHOO]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[SapientNitro]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[Selects]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Their]]></category>
		<category><![CDATA[Value]]></category>

		<guid isPermaLink="false">http://www.weez.com/2010/07/sapientnitro-selects-kenshoo-as-technology-of-choice-to-optimize-value-of-search-engine-marketing-for-their-clients/</guid>
		<description><![CDATA[SapientNitro Selects KENSHOO as Technology of Choice to Optimize Value of Search Engine Marketing for their Clients KENSHOO helps boost ROI of online ad spend for high profile international brands, including Hugo Boss and TracFone Read more on PRWeb via Yahoo! News]]></description>
			<content:encoded><![CDATA[<p><b>SapientNitro Selects KENSHOO as Technology of Choice to Optimize Value of Search Engine Marketing for their Clients</b><br />
KENSHOO helps boost ROI of online ad spend for high profile international brands, including Hugo Boss and TracFone</p>
<p>Read more on <a rel="nofollow" href="http://news.yahoo.com/s/prweb/20100722/bs_prweb/prweb4290474_1">PRWeb via Yahoo! News</a><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.weez.com/2010/07/sapientnitro-selects-kenshoo-as-technology-of-choice-to-optimize-value-of-search-engine-marketing-for-their-clients/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Optimizations on Linux</title>
		<link>http://www.weez.com/2008/09/mysql-optimizations-on-linux/</link>
		<comments>http://www.weez.com/2008/09/mysql-optimizations-on-linux/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 07:04:58 +0000</pubDate>
		<dc:creator>Abidoon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[cflags]]></category>
		<category><![CDATA[cxxflags]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[optimize]]></category>

		<guid isPermaLink="false">http://www.weez.com/?p=22</guid>
		<description><![CDATA[It is important to optimize all pieces of the LAMP acronym and MySQL is not exception to the rule when deploying on the live servers Here be the compile time flags. export CFLAGS=&#8221;-O3 -march=cpu -pipe -msse2 -m3dnow -fomit-frame-pointer -mtune=cpu&#8221; CXX=gcc CXXFLAGS=&#8221;-O3 -cpu -felide-constructors -fno-exceptions -fno-rtti&#8221; As mentioned in my previous entry you can go check [...]]]></description>
			<content:encoded><![CDATA[<p>It is important to optimize all pieces of the LAMP acronym and MySQL is not exception to the rule when deploying on the live servers</p>
<p>Here be the compile time flags.</p>
<p>export CFLAGS=&#8221;-O3 -march=cpu -pipe -msse2 -m3dnow -fomit-frame-pointer -mtune=cpu&#8221; CXX=gcc CXXFLAGS=&#8221;-O3 -cpu -felide-constructors -fno-exceptions -fno-rtti&#8221; </p>
<p>As mentioned in my previous entry you can go check the GCC Manual pages to replace the cpu keyword in the mtune and march in the CFLAGS and the -cpu in the CXXFLAGS.</p>
<p>I got approximately a 5% performance boost with these during benchmarking.</p>
<p>Please note though that the developer team got a much bigger increase in performance when they optimized the tables by adding indexes and improving their queries.</p>
<p>In general we also found that a simple select query took about twice as much time when the table was using InnoDB compared to MyISAM.</p>
<p>I am open to any additional feedback and ideas anyone may have. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.weez.com/2008/09/mysql-optimizations-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Optimizations</title>
		<link>http://www.weez.com/2008/09/php-optimizations/</link>
		<comments>http://www.weez.com/2008/09/php-optimizations/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 00:11:01 +0000</pubDate>
		<dc:creator>Abidoon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[recompile]]></category>

		<guid isPermaLink="false">http://www.weez.com/?p=3</guid>
		<description><![CDATA[How to get additional performance out of php.]]></description>
			<content:encoded><![CDATA[<p>Anyone ever try and optimize PHP recently?</p>
<p>The following settings worked really well for me</p>
<p>1 &#8211; export CFLAGS=&#8221;-march=cpu -O3 -pipe -msse2 -m3dnow -fomit-frame-pointer -mtune=cpu&#8221;</p>
<p>Based on whatever processor architecture you were using you should then replace the cpu in the above line with the name of the processor as described in <a href="http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html" rel="nofollow" target="new">GCC Manual</a></p>
<p>2 &#8211; Try configuring with the following flags added: &#8211;enable-inline-optimization</p>
<p>3 &#8211; Once compiled use strip to reduce the PHP binary size like so -&gt; strip php-cgi <img src='http://www.weez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>4 &#8211; For a significant performance boost I would recommend the installation of an opcode cache such as x-cache. If you don&#8217;t know what an opcode cacher is or does go <a href="http://en.wikipedia.org/wiki/PHP_accelerator" rel="nofollow" target="new"/>here</a></p>
<p>The above mentioned optimizations led to more than 50% increase in speed and a more than 50% drop in cpu usage. Please feel free to make additional suggestions on how I can squeeze more performance  out <img src='http://www.weez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  !</p>
<p>Cheers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.weez.com/2008/09/php-optimizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

