<?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>MySQL Performance Blog &#187; Innodb</title>
	<atom:link href="http://www.mysqlperformanceblog.com/category/innodb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 03:11:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How innodb_open_files affects performance</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/18/how-innodb_open_files-affects-performance/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/11/18/how-innodb_open_files-affects-performance/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 02:58:56 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1764</guid>
		<description><![CDATA[Recently I looked at table_cache sizing which showed larger table cache does not always provides the best performance.  So I decided to look at yet another similar variable &#8211; innodb_open_files which defines how many files Innodb will keep open while working in innodb_file_per_table mode.
Unlike MyISAM  Innodb does not have to keep open file [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I <a href="http://www.mysqlperformanceblog.com/2009/11/16/table_cache-negative-scalability/">looked at table_cache sizing</a> which showed larger table cache does not always provides the best performance.  So I decided to look at yet another similar variable &#8211; <strong>innodb_open_files</strong> which defines how many files Innodb will keep open while working in <strong>innodb_file_per_table</strong> mode.</p>
<p>Unlike MyISAM  Innodb does not have to keep open file descriptor when table is open &#8211; open table is purely logical state and appropriate .ibd file may be open or closed.   Furthermore  besides MySQL <strong>table_cache</strong> Innodb maintains its own (called data dictionary) which keeps all tables ever accessed since table start &#8211; there is no variable to control its size and it can take significant amount of memory in some edge cases.   Percona patches though provide <strong>innodb_dict_size_limit</strong> to restrict growth of data dictionary.</p>
<p>So I started with same series of test and creating 100.000 tables with single integer column.  The process of creating tables took about <strong>45 minutes</strong> which is a lot more than MyISAM and the total size on disk was <strong>12GB</strong>  in .ibd files plus some space allocated in system tablespace.  So if you create Innodb tables you better store some data in them otherwise there will be a huge waste of space.</p>
<p>I used MySQL 5.4.2 for tests which should be as good as it gets in terms of optimizations in this space.</p>
<p>To keep test alligned to my previous experiments I was running with <strong>table_open_cache=64</strong> and tried <strong>innodb_open_files=64 and 16384</strong>.</p>
<p>Reading 100.000 tables first time after MySQL time takes about 500 seconds  (so it is some <strong>200 tables/sec</strong>) &#8211; first time Innodb actually populates data dictionary.  The second time we do same operation it takes about 25 seconds (4.000 tables/sec) which is quite a difference.   As we can see even in case table it fully in Innodb data dictionary the operation is slower than MyISAM tables. Though the difference can be related to the size of set of empty tables which is about 10 times smaller for MyISAM.  </p>
<p>I found no significant difference whatever limit of open files was, which is not surprising as logical operation of opening file is rather fast on local file system &#8211; one can open/close file hundreds of thousands times per second.</p>
<p>To verify this I tried doing &#8220;open table&#8221; test for only 10K out of 100K tables &#8211; the performance was about the same, taking 1sec (on the second time) . Whenever innodb_open_files_limit was 64 (virtually all misses ) or 16384 (all hits) performance was the same.</p>
<p>As I mentioned Data Dictionary can take considerable amount of memory &#8211; In my case after reading all tables I got<strong> &#8220;Dictionary memory allocated 392029720&#8243; </strong> which means very simple single tables takes about 4KB of space in data dictionary.  More complicated tables can take a bit more. </p>
<p>So innodb_open_files does not affect performance a lot on reads &#8211; what is about writes ?  I tried again very simple test inserting the row in each of 100K tables.  This test ran  about 180sec first time and about 260sec second time (with<strong> innodb_flush_log_at_trx_commit=0</strong>) go giving  550 and 380 updates/sec appropriately.    Why was second time slower and not faster ?  Because on the second run there were a lot of dirty pages in innodb buffer pool which had to be flushed before recycling.   First ran however was done with clean buffer pool (after reading all tables once)</p>
<p>Same as with select case I could not see any measurable difference between two tested <strong>innodb_open_files</strong> values.</p>
<p>Finally I decided to test the crash recovery &#8211; does it make any difference ? </p>
<p>The crash recovery in Innodb is nasty if you have a lot of tables:</p>
<blockquote><p>
091118 18:43:36  InnoDB: Database was not shut down normally!<br />
InnoDB: Starting crash recovery.<br />
InnoDB: Reading tablespace information from the .ibd files&#8230;<br />
InnoDB: Restoring possible half-written data pages from the doublewrite<br />
InnoDB: buffer&#8230;<br />
InnoDB: Doing recovery: scanned up to log sequence number 12682768136<br />
091118 18:47:44  InnoDB: Starting an apply batch of log records to the database&#8230;
</p></blockquote>
<p>If Innodb detects it is not shut down properly it will scan all .ibd files which took a bit over 4 minutes for 100K tables but which obviously can take a lot more if there are more tables or they are less cached than in this case.    This part of data recovery does not depends on amount of records which need to be applied just about number of tables.</p>
<p>With innodb_open_files=64  I got bunch of warning messages during recovery:</p>
<blockquote><p>
091118 18:47:44  InnoDB: Warning: too many (67) files stay open while the maximum<br />
InnoDB: allowed value would be 64.<br />
InnoDB: You may need to raise the value of innodb_max_files_open in<br />
InnoDB: my.cnf.<br />
InnoDB: fil_sys open file LRU len 0<br />
091118 18:47:44  InnoDB: Warning: too many (68) files stay open while the maximum<br />
InnoDB: allowed value would be 64.<br />
InnoDB: You may need to raise the value of innodb_max_files_open in<br />
InnoDB: my.cnf
</p></blockquote>
<p>So we can see Innodb may with to have so many open files during recovery stage and it will open more files than allowed if needed.</p>
<p>Both scanning open files and applying logs took about 9 minutes in this setup.  This number of course can change a lot depending on hardware log file size workload and even when crash happen (how many unflushed changes we had)</p>
<p>Repeating test with <strong>innodb_open_files=16384</strong> I got about same crash recovery speed though with no warnings. </p>
<p>So it looks like innodb_open_files_limit=300  is not being that large liability even with large number of tables and you can also safely increase this number if you like &#8211; there is no any surprises such as surprised slow downs for replacing open files in the list.  I guess Heikki knows how to implement LRU in the end <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by peter |
      <a href="http://www.mysqlperformanceblog.com/2009/11/18/how-innodb_open_files-affects-performance/#comments">2 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/11/18/how-innodb_open_files-affects-performance/&amp;title=How innodb_open_files affects performance" 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/2009/11/18/how-innodb_open_files-affects-performance/&amp;title=How innodb_open_files affects performance" 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/2009/11/18/how-innodb_open_files-affects-performance/&amp;title=How innodb_open_files affects performance" 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/2009/11/18/how-innodb_open_files-affects-performance/&amp;T=How innodb_open_files affects performance" 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/2009/11/18/how-innodb_open_files-affects-performance/&amp;title=How innodb_open_files affects performance" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/11/18/how-innodb_open_files-affects-performance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>InnoDB: look after fragmentation</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/05/innodb-look-after-fragmentation/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/11/05/innodb-look-after-fragmentation/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 19:01:54 +0000</pubDate>
		<dc:creator>Vadim</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1616</guid>
		<description><![CDATA[One problem made me puzzled for couple hours, but it was really interesting to figure out what's going on. 
So let me introduce problem at first. The table is
PLAIN TEXT
CODE:




CREATE TABLE `c` &#40;


&#160; `tracker_id` int&#40;10&#41; unsigned NOT NULL,


&#160; `username` char&#40;20&#41; character set latin1 collate latin1_bin NOT NULL,


&#160; `time_id` date NOT NULL,


&#160; `block_id` int&#40;10&#41; unsigned default [...]]]></description>
			<content:encoded><![CDATA[<p>One problem made me puzzled for couple hours, but it was really interesting to figure out what's going on. </p>
<p>So let me introduce problem at first. The table is</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<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;">CREATE TABLE `c` <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; `tracker_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</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; `username` char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">20</span><span style="color:#006600; font-weight:bold;">&#41;</span> character set latin1 collate latin1_bin NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `time_id` date NOT NULL,</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; `block_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned default NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; PRIMARY KEY&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span>`tracker_id`,`username`,`time_id`<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; KEY `block_id` <span style="color:#006600; font-weight:bold;">&#40;</span>`block_id`<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 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Table has 11864696 rows and takes Data_length: 698,351,616 bytes on disk</p>
<p>The problem is that after restoring table from mysqldump, the query that scans data by primary key was slow. How slow ? Let me show.</p>
<p>The query in question is (Q1):</p>
<p><code>SELECT count(distinct username) FROM  tracker where TIME_ID >= '2009-07-20 00:00:00' AND TIME_ID <= '2009-10-21 00:00:00' AND (tracker_id=437)<br />
</code></p>
<p>On cold buffer_pool, it took:</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| count<span style="color:#006600; font-weight:bold;">&#40;</span>distinct username<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#800000;color:#800000;">5856156</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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">4</span> min <span style="color:#800000;color:#800000;">13</span>.<span style="color:#800000;color:#800000;">61</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>However the query (again on cold buffer_pool) (Q2)</p>
<p><code>SELECT count(distinct username) FROM  tracker where TIME_ID >= '2009-07-20 00:00:00' AND TIME_ID <= '2009-10-21 00:00:00'<br />
</code></p>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| count<span style="color:#006600; font-weight:bold;">&#40;</span>distinct username<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#800000;color:#800000;">5903053</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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">18</span>.<span style="color:#800000;color:#800000;">81</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Difference is impressive. <strong>4 min 13.61 sec</strong> vs <strong>18.81 sec</strong></p>
<p>If you want EXPLAIN plain, here it is:</p>
<p>For Q1:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<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;">+----+-------------+-------------------------+------+---------------+---------+---------+-------+---------+--------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| id | select_type | table&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| type | possible_keys | key&nbsp; &nbsp; &nbsp;| key_len | ref&nbsp; &nbsp;| rows&nbsp; &nbsp; | Extra&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;">+----+-------------+-------------------------+------+---------------+---------+---------+-------+---------+--------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color:#800000;color:#800000;">1</span> | SIMPLE&nbsp; &nbsp; &nbsp; | tracker&nbsp; | ref&nbsp; | PRIMARY&nbsp; &nbsp; &nbsp; &nbsp;| PRIMARY | <span style="color:#800000;color:#800000;">4</span>&nbsp; &nbsp; &nbsp; &nbsp;| const | <span style="color:#800000;color:#800000;">6880241</span> | Using where; Using index | </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;">+----+-------------+-------------------------+------+---------------+---------+---------+-------+---------+--------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">02</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>For Q2:</p>
<div class="igBar"><span id="lcode-17"><a href="#" onclick="javascript:showPlainTxt('code-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-17">
<div class="code">
<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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+--------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| id | select_type | table&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| type&nbsp; | possible_keys | key&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| key_len | ref&nbsp; | rows&nbsp; &nbsp; &nbsp;| Extra&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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+--------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color:#800000;color:#800000;">1</span> | SIMPLE&nbsp; &nbsp; &nbsp; | tracker | index | NULL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | block_id | <span style="color:#800000;color:#800000;">5</span>&nbsp; &nbsp; &nbsp; &nbsp;| NULL | <span style="color:#800000;color:#800000;">13760483</span> | Using where; Using index | </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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+--------------------------+ </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Query Q1 is executed using Primary Key, and Query Q2 is using block_id key.</p>
<p>To get more details I ran both queries with our extended stats in slow.log (available in 5.0-percona releases)</p>
<p>So for query Q1:</p>
<div class="igBar"><span id="lcode-18"><a href="#" onclick="javascript:showPlainTxt('code-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-18">
<div class="code">
<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;"># Query_time: <span style="color:#800000;color:#800000;">253</span>.<span style="color:#800000;color:#800000;">643162</span>&nbsp; Lock_time: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000137</span>&nbsp; Rows_sent: <span style="color:#800000;color:#800000;">1</span>&nbsp; Rows_examined: <span style="color:#800000;color:#800000;">11569733</span>&nbsp; Rows_affected: <span style="color:#800000;color:#800000;">0</span>&nbsp; Rows_read: <span style="color:#800000;color:#800000;">11569733</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#&nbsp; &nbsp;InnoDB_IO_r_ops: <span style="color:#800000;color:#800000;">73916</span>&nbsp; InnoDB_IO_r_bytes: <span style="color:#800000;color:#800000;">1211039744</span>&nbsp; InnoDB_IO_r_wait: <span style="color:#800000;color:#800000;">236</span>.<span style="color:#800000;color:#800000;">149003</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; &nbsp;InnoDB_rec_lock_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</span>&nbsp; InnoDB_queue_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#&nbsp; &nbsp;InnoDB_pages_distinct: <span style="color:#800000;color:#800000;">54838</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And for query Q2:</p>
<div class="igBar"><span id="lcode-19"><a href="#" onclick="javascript:showPlainTxt('code-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-19">
<div class="code">
<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;"># Query_time: <span style="color:#800000;color:#800000;">18</span>.<span style="color:#800000;color:#800000;">846855</span>&nbsp; Lock_time: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000123</span>&nbsp; Rows_sent: <span style="color:#800000;color:#800000;">1</span>&nbsp; Rows_examined: <span style="color:#800000;color:#800000;">11864696</span>&nbsp; Rows_affected: <span style="color:#800000;color:#800000;">0</span>&nbsp; Rows_read: <span style="color:#800000;color:#800000;">11864696</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#&nbsp; &nbsp;InnoDB_IO_r_ops: <span style="color:#800000;color:#800000;">27510</span>&nbsp; InnoDB_IO_r_bytes: <span style="color:#800000;color:#800000;">450723840</span>&nbsp; InnoDB_IO_r_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">165124</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; &nbsp;InnoDB_rec_lock_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</span>&nbsp; InnoDB_queue_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#&nbsp; &nbsp;InnoDB_pages_distinct: <span style="color:#800000;color:#800000;">24687</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As you see for Q1 IO read took <strong>236.149003 sec</strong> vs <strong>0.165124</strong> for Q2.  But Q1 is scan by primary key, which supposed to be<br />
sequential!</p>
<p>Let's see on another statistic, which available in innodb_check_fragmentation patch:</p>
<p>for Q1:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<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;">SHOW STATUS LIKE <span style="color:#CC0000;">'Innodb_scan_pages%'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Variable_name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Value |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Innodb_scan_pages_contiguous | <span style="color:#800000;color:#800000;">88</span>&nbsp; &nbsp; | </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| Innodb_scan_pages_jumpy&nbsp; &nbsp; &nbsp; | <span style="color:#800000;color:#800000;">73789</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;">+------------------------------+-------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">2</span> rows in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">00</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>and for Q2:</p>
<div class="igBar"><span id="lcode-21"><a href="#" onclick="javascript:showPlainTxt('code-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-21">
<div class="code">
<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;">mysql&gt; SHOW STATUS LIKE <span style="color:#CC0000;">'Innodb_scan_pages%'</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Variable_name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Value |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Innodb_scan_pages_contiguous | <span style="color:#800000;color:#800000;">26959</span> | </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| Innodb_scan_pages_jumpy&nbsp; &nbsp; &nbsp; | <span style="color:#800000;color:#800000;">442</span>&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;">+------------------------------+-------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">2</span> rows in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">00</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So you see for Q1 it was not sequential scan, even it is primary key, but it is sequential for Q2.</p>
<p>So what's the answer ? It's <strong>fragmentation</strong> of primary key (and whole data table, as InnoDB data == primary key). But how it could happen with<br />
primary key after mysqldump ? The answer here if we look on </p>
<p>EXPLAIN SELECT * FROM tracker;</p>
<div class="igBar"><span id="lcode-22"><a href="#" onclick="javascript:showPlainTxt('code-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-22">
<div class="code">
<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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+-------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| id | select_type | table&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| type&nbsp; | possible_keys | key&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| key_len | ref&nbsp; | rows&nbsp; &nbsp; &nbsp;| Extra&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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+-------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; <span style="color:#800000;color:#800000;">1</span> | SIMPLE&nbsp; &nbsp; &nbsp; | tracker | index | NULL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | block_id | <span style="color:#800000;color:#800000;">5</span>&nbsp; &nbsp; &nbsp; &nbsp;| NULL | <span style="color:#800000;color:#800000;">13760483</span> | Using index | </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;">+----+-------------+-------------------------+-------+---------------+-------------------------------------+---------+------+----------+-------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">00</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>We see that dump is taken in key "block_id" order, not in primary key order. And later when we load this table, INSERTS into primary key happens in random order, and that gives us the fragmentation we see here.</p>
<p>How to fix it in our case. It's easy: <code>ALTER TABLE tracker ENGINE=InnoDB</code>, it will force InnoDB to rebuild table in primary key order.</p>
<p>After that Q1:</p>
<div class="igBar"><span id="lcode-23"><a href="#" onclick="javascript:showPlainTxt('code-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-23">
<div class="code">
<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| count<span style="color:#006600; font-weight:bold;">&#40;</span>distinct username<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#800000;color:#800000;">5856156</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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">17</span>.<span style="color:#800000;color:#800000;">72</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; SHOW STATUS LIKE <span style="color:#CC0000;">'Innodb_scan_pages%'</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;">+------------------------------+-------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| Variable_name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Value |</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;">+------------------------------+-------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| Innodb_scan_pages_contiguous | <span style="color:#800000;color:#800000;">37864</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;">| Innodb_scan_pages_jumpy&nbsp; &nbsp; &nbsp; | <span style="color:#800000;color:#800000;">574</span>&nbsp; &nbsp;| </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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:#800000;color:#800000;">2</span> rows in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">00</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;">and extended stats:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Query_time: <span style="color:#800000;color:#800000;">17</span>.<span style="color:#800000;color:#800000;">765369</span>&nbsp; Lock_time: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000137</span>&nbsp; Rows_sent: <span style="color:#800000;color:#800000;">1</span>&nbsp; Rows_examined: <span style="color:#800000;color:#800000;">11569733</span>&nbsp; Rows_affected: <span style="color:#800000;color:#800000;">0</span>&nbsp; Rows_read: <span style="color:#800000;color:#800000;">11569733</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; &nbsp;InnoDB_IO_r_ops: <span style="color:#800000;color:#800000;">38530</span>&nbsp; InnoDB_IO_r_bytes: <span style="color:#800000;color:#800000;">631275520</span>&nbsp; InnoDB_IO_r_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">204893</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#&nbsp; &nbsp;InnoDB_rec_lock_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</span>&nbsp; InnoDB_queue_wait: <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">000000</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; &nbsp;InnoDB_pages_distinct: <span style="color:#800000;color:#800000;">35584</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You see that time returned to appropriate <strong>17.72 sec</strong>.</p>
<p>You may ask what happens now with Q2 ? yes, it's getting slow now, as we made key "block_id" inserted not in order. </p>
<div class="igBar"><span id="lcode-24"><a href="#" onclick="javascript:showPlainTxt('code-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-24">
<div class="code">
<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| count<span style="color:#006600; font-weight:bold;">&#40;</span>distinct username<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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#800000;color:#800000;">5903053</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;">+---------------------------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> row in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">2</span> min <span style="color:#800000;color:#800000;">8</span>.<span style="color:#800000;color:#800000;">92</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;">mysql&gt; SHOW STATUS LIKE <span style="color:#CC0000;">'Innodb_scan_pages%'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Variable_name&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Value |</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">+------------------------------+-------+</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;">| Innodb_scan_pages_contiguous | <span style="color:#800000;color:#800000;">45</span>&nbsp; &nbsp; | </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">| Innodb_scan_pages_jumpy&nbsp; &nbsp; &nbsp; | <span style="color:#800000;color:#800000;">35904</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;">+------------------------------+-------+</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">2</span> rows in set <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">00</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As for mysqldump you may use <code>--order-by-primary</code>  options to force dump in primary key order.</p>
<p>So notes to <strong>highlight</strong>:</p>
<ul>
<li>InnoDB fragmentation may hurt your query significantly, especially when data is not in buffer_pool and execution goes to read from disk</li>
<li>Fragmentation by secondary key is much more likely than by primary key, and you cannot really control it (tough it is possible in XtraDB / InnoDB-plugin with FAST INDEX creation) so be careful with queries scan many records by secondary key</li>
<li>To check if you query affected by fragmentation you can use  <code>Innodb_scan_pages_contiguous ; Innodb_scan_pages_jumpy</code> statistics in 5.0-percona releases (coming to 5.1-XtraDB soon)</li>
</ul>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Vadim |
      <a href="http://www.mysqlperformanceblog.com/2009/11/05/innodb-look-after-fragmentation/#comments">7 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/11/05/innodb-look-after-fragmentation/&amp;title=InnoDB: look after fragmentation" 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/2009/11/05/innodb-look-after-fragmentation/&amp;title=InnoDB: look after fragmentation" 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/2009/11/05/innodb-look-after-fragmentation/&amp;title=InnoDB: look after fragmentation" 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/2009/11/05/innodb-look-after-fragmentation/&amp;T=InnoDB: look after fragmentation" 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/2009/11/05/innodb-look-after-fragmentation/&amp;title=InnoDB: look after fragmentation" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/11/05/innodb-look-after-fragmentation/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Speaking at the LA MySQL Meetup &#8211; 18th November</title>
		<link>http://www.mysqlperformanceblog.com/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 17:35:44 +0000</pubDate>
		<dc:creator>Morgan Tocker</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[xtradb]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1478</guid>
		<description><![CDATA[
A recent photo from Highload.ru
I said in my last post, that we're interested in speaking at MySQL meetups, and I'm happy to say that the Los Angeles MySQL Meetup has taken us up on the offer.
On November 18th, I'll be giving an introductory talk on InnoDB/XtraDB Performance Optimization.  I will be the second speaker, with [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; padding: 4px; margin: 5px"><img title="Morgan speaking at Highload.ru" src="http://tocker.id.au/files/percona/highload_talk.jpg" alt="Morgan speaking at Highload.ru" width="300" height="192" /><br />
A recent photo from Highload.ru</div>
<p>I said in my <a href="../2009/10/16/training-updates/">last post</a>, that we're interested in speaking at MySQL meetups, and I'm happy to say that the Los Angeles MySQL Meetup has taken us up on the offer.</p>
<p>On November 18th, I'll be giving an introductory talk on <a href="http://www.meetup.com/lamysql/calendar/11742534/">InnoDB/XtraDB Performance Optimization</a>.  I will be the second speaker, with <strong>Carl Gelbart</strong> first speaking on Infobright.</p>
<p>What brings me to LA?  On the same day (18th Nov) I'll be teaching a one day class on <a href="http://percona-ca-la.eventbrite.com/">Performance Optimization for MySQL with InnoDB and XtraDB</a>.  If you haven't signed up yet - spaces are still available.</p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Morgan Tocker |
      <a href="http://www.mysqlperformanceblog.com/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/#comments">No comment</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/&amp;title=Speaking at the LA MySQL Meetup &#8211; 18th November" 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/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/&amp;title=Speaking at the LA MySQL Meetup &#8211; 18th November" 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/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/&amp;title=Speaking at the LA MySQL Meetup &#8211; 18th November" 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/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/&amp;T=Speaking at the LA MySQL Meetup &#8211; 18th November" 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/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/&amp;title=Speaking at the LA MySQL Meetup &#8211; 18th November" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/11/01/speaking-at-the-la-mysql-meetup-18th-november/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>State of the art: Galera &#8211; synchronous replication for InnoDB</title>
		<link>http://www.mysqlperformanceblog.com/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 15:08:58 +0000</pubDate>
		<dc:creator>Vadim</dc:creator>
				<category><![CDATA[High Availability]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[replication]]></category>
		<category><![CDATA[xtradb]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1556</guid>
		<description><![CDATA[First time I heard about Galera on Percona Performance Conference 2009, Seppo Jaakola was presenting "Galera: Multi-Master Synchronous MySQL Replication Clusters". It was impressed as I personally always wanted it for InnoDB, but we had it in plans at the bottom of the list, as this is very hard to implement properly.
The idea by itself [...]]]></description>
			<content:encoded><![CDATA[<p>First time I heard about Galera on Percona Performance Conference 2009, Seppo Jaakola was presenting <a href="http://www.percona.com/ppc2009/PPC2009_galera.pdf">"Galera: Multi-Master Synchronous MySQL Replication Clusters"</a>. It was impressed as I personally always wanted it for InnoDB, but we had it in plans at the bottom of the list, as this is very hard to implement properly.<br />
The idea by itself is not new, I remember synchronous replication was announced for SolidDB on MySQL UC 2007, but later the product was killed by IBM.</p>
<p>So long time after PPC 2009 there was available version mysql-galera-0.6, which had serious flow, to setup a new node you had to take down whole cluster. And all this time Codership ( company that develops Galera) was working on 0.7 release that introduces node propagation keeping cluster online. You can play with 0.7pre release by yourself <a href="http://www.codership.com/en/downloads/galera">MySQL/Galera Release 0.7pre</a>. </p>
<p>In current version propagation is done by mysqldump from one of nodes ("donor"). In next release Codership is going to support LVM snapshot and xtrabackup which will make the setup of new node even easier. The current annoyance I see is that if you shutdown one node for short period of time for quick maintenance, after  start, the node has to load whole mysqldump, like it is new empty node. I hope Codership guys will address this also.<br />
Another thing I miss for now is support of InnoDB-plugin, which as we know performs much better than standard InnoDB &reg;.</p>
<p>So what is so interesting about Galera. Couple things:</p>
<p>- High Availability. Any of N standby nodes are available immediately when main node fails. Galera is serious pretender to be included to the list, Yves put recently, <a href="http://www.mysqlperformanceblog.com/2009/10/16/finding-your-mysql-high-availability-solution-%e2%80%93-the-questions/">http://www.mysqlperformanceblog.com/2009/10/16/finding-your-mysql-high-availability-solution-%e2%80%93-the-questions/</a>. I am not sure how many nines it will provide <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but efforts on test setup and deployment should be comparable with MMM setup.</p>
<p>- Scale Writes. Galera allows to write to any of N nodes and automatically propagate to other nodes. It sounds too ideal, and there is drawback - with increasing amount of nodes you write to, your transaction rollback rate may increase, especially if you working on the same dataset. You can find some results on <a href="http://www.codership.com/en/content/benchmarking-write-scalability">Codership's page</a>,  and I am going to run my own benchmarks also. Also from benchmark you can see that communication overhead maybe significant for short writes.</p>
<p>- Scale Reads. It can be done with regular replication, but  with synchronous your "slaves-nodes" are in the same state, there is no "slave behind". When you read from any slave, you read actual data. Although it also has serious drawback -  our cluster is fast as fast the "weakest" node in the chain. So if one node gets overloaded and performance degrades, the same happens with whole cluster.</p>
<p>- Heterogeneous-database replication. It is not here yet, and I do not know what's in Codership roadmap, but group manager protocol in Galera is database independent, and it's only matter of database drivers. For InnoDB currently it is set of patches, and I see it is quite possible to make the same for Postgres. So MySQL-Postgres cluster setup is not so far ahead <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>On <a href="http://www.codership.com/en/company/about">"Company page" Codership says</a> their goal is "to promote and exploit the latest developments in computer science to produce fast and scalable synchronous replication solution that "just works" for databases and similar applications", which I think they have success in. Implementing fast, scalable and working group communication and transaction manager is the art.</p>
<p>As for now I would not put 0.7 release into production yet, but you may seriously consider to play with it in test environment, and report bugs to Codership team, they are very responsive.<br />
I am waiting for next releases and looking to make integration with XtraDB.</p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Vadim |
      <a href="http://www.mysqlperformanceblog.com/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/#comments">6 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/&amp;title=State of the art: Galera &#8211; synchronous replication for InnoDB" 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/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/&amp;title=State of the art: Galera &#8211; synchronous replication for InnoDB" 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/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/&amp;title=State of the art: Galera &#8211; synchronous replication for InnoDB" 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/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/&amp;T=State of the art: Galera &#8211; synchronous replication for InnoDB" 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/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/&amp;title=State of the art: Galera &#8211; synchronous replication for InnoDB" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/10/27/state-of-the-art-galera-synchronous-replication-for-innodb/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tuning for heavy writing workloads</title>
		<link>http://www.mysqlperformanceblog.com/2009/10/14/tuning-for-heavy-writing-workloads/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/10/14/tuning-for-heavy-writing-workloads/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 00:06:55 +0000</pubDate>
		<dc:creator>Yasufumi</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[benchmarks]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[xtradb]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1376</guid>
		<description><![CDATA[For the my previous post, there was comment to suggest to test db_STRESS benchmark on XtraDB by Dimitri. And I tested and tuned for the benchmark. I will show you the tunings. It should be also tuning procedure for general heavy writing workloads.
At first, &#60;tuning peak performance&#62;. The next, &#60;tuning purge operation&#62; to stabilize performance  [...]]]></description>
			<content:encoded><![CDATA[<p>For the <a href="http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/">my previous post</a>, there was comment to suggest to test <a href="http://dimitrik.free.fr/">db_STRESS benchmark</a> on XtraDB by Dimitri. And I tested and tuned for the benchmark. I will show you the tunings. It should be also tuning procedure for general heavy writing workloads.</p>
<p>At first, &lt;tuning peak performance&gt;. The next, &lt;tuning purge operation&gt; to stabilize performance  and to avoid decreasing performance.</p>
<p><strong>&lt;test condition&gt;</strong></p>
<p>Server:<br />
PowerEdge R900, Four Quad Core E7320 Xeon, 2.13GHz, 32GB Memory, 16X2GB, 667MHz</p>
<p>db_STRESS:<br />
32 sessions, RW=1, dbsize = 1000000, no thinktime</p>
<p>XtraDB: (mysql-5.1.39 + XtraDB-1.0.4-current)<br />
innodb_io_capacity = 4000<br />
innodb_support_xa = false<br />
innodb_file_per_table = true<br />
innodb_buffer_pool_size = 16G<br />
innodb_read_io_threads = 8<br />
innodb_write_io_threads = 8<br />
innodb_flush_log_at_trx_commit = 2<br />
innodb_log_buffer_size = 128M<br />
innodb_log_file_size = 512M<br />
innodb_log_files_in_group = 2<br />
innodb_max_dirty_pages_pct = 90<br />
innodb_flush_method = O_DIRECT<br />
(the followings are XtraDB specific general settings)<br />
innodb_ibuf_active_contract = 1<br />
innodb_adaptive_flushing = false<br />
innodb_adaptive_checkpoint = estimate</p>
<p><strong>&lt;tuning peak performance&gt;</strong></p>
<p>At first, tuning the peak performance to use CPU and IO resource more effectively. To avoid mutex/lock contentions are good to use more CPU resource of many CPUs.</p>
<p><img class="alignnone size-full wp-image-1381" title="purge_thread_test_1ST_TUNE" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/10/purge_thread_test_1ST_TUNE.png" alt="purge_thread_test_1ST_TUNE" width="299" height="238" /></p>
<p>This graph shows the peak performance in tps of db_STRESS.</p>
<p>At current settings, <strong>"base"</strong> in the graph is the perfomance. We can confirm the mutex/lock contention roughly by the SEMAPHORES sction of SHOW INNODB STATUS output.</p>
<p><em>"xx-lock on RW-latch at 0x7f2ff40a3dc0 created in file dict/dict0dict.c line 1627"</em></p>
<p>It is index-&gt;lock, viewing the source file (and it may be HISTORY table). This is the lock for each index tree. We may be able to disperse the lock using by the partitioning of MySQL. Added the following clause to the HISTORY table definition.</p>
<p style="text-align: center;"><strong>"PARTITION BY HASH(REF_OBJECT) PARTITIONS 16"</strong></p>
<p>Now the performance became to <strong>"+partitioned"</strong> in the graph. Looking the SEMAPHORES section again,</p>
<p><em>"has waited at handler/ha_innodb.cc line 7275 for 0.0000 seconds the semaphore:<br />
X-lock on RW-latch at 0xd30320 created in file dict/dict0dict.c line 623"</em></p>
<p>may be the line which appears for the most times (it is dict_operation_lock). It may be partition specific lock contention. The current XtraDB has the variable to tune the contention.</p>
<p style="text-align: center;"><strong>innodb_stats_update_need_lock = 0</strong> (default 1)</p>
<p>It skip the updating statistics which needs the lock. (it only affects for "Data_free:" value of TABLE STATS). And the performance became <strong>"+skip_stats"</strong> in the graph.  Then, the next contention at SEMAPHORES section is...</p>
<p><em>"Mutex at 0x1b3e3e78 created file trx/trx0rseg.c line 167"</em></p>
<p>may be remarkable (it is rseg-&gt;mutex). The mutex is for each rollback segments, so we can increase the rsegs to solve the contention problem. XtraDB can increase the rseg.</p>
<p style="text-align: center;"><strong>innodb_extra_rsegments = 64</strong> (affects to initialization of InnoDB)</p>
<p>Recreated database files with the parameter. Then the performance became <strong>"+rsegs64"</strong>. At last, the next contention may be <em>"Mutex at 0x28ce8e0 created file srv/srv0srv.c line 982". </em>It is kernel_mutex, currently we don't have proper solution for that. The setting seems to be enough for now.</p>
<p><strong>&lt;tuning purge operation&gt;</strong></p>
<p>Next, looking the sequential result in more long term.</p>
<p>The next problem is "History list length" growing to huge size. The value is the number of entries in rollback segment. The entries are used for consistent reading of the older transactions. They can be removed when any transactions doesn't refer the entry. This removing operation for the entries is called "purge" in InnoDB. The purge operation should be done enough on time, because the huge history list affects to performance.</p>
<p>Basically, the purging is done by master_thread (general background thread of InnoDB). The huge history list makes the purge operation slow, and it interferes  with the other tasks of the master_thread (e.g. flushing dirty blocks, treating insert buffer, etc...). <a href="http://dimitrik.free.fr/blog/index.html">Dimitri</a> implemented a purge_thread to devote to the purging, and also XtraDB has similar purge_thread. Though it seems to make the throughput stabilize, it is not enough still for heavy update workloads. A single purge_thread on one CPU is not enough for updates from user threads on the all of other CPUs.</p>
<p>XtraDB can increase the purge_threads from the next release.</p>
<p style="text-align: center;"><strong>innodb_use_purge_thread = 4</strong></p>
<p style="text-align: left;">seems to be enough for this workload on the server.</p>
<p style="text-align: left;">The first graph of followings is sequential throughput [tps] up to 3500 sec.</p>
<p><img class="alignnone size-full wp-image-1388" title="purge_thread_test_TPS" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/10/purge_thread_test_TPS.png" alt="purge_thread_test_TPS" width="675" height="377" /></p>
<p>The next is tracking the "History list length" at the same time.</p>
<p><img class="alignnone size-full wp-image-1389" title="purge_thread_test_HIST_LENGTH" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/10/purge_thread_test_HIST_LENGTH.png" alt="purge_thread_test_HIST_LENGTH" width="675" height="377" /></p>
<pre>"Norm 1.0.4": Normal InnoDB Plugin 1.0.4 without XtraDB specific options
"xtra p_t 0": XtraDB 1.0.4-new (no purge_thread)
"xtra p_t 1": XtraDB 1.0.4-new (single purge_thread similar to Dimitri's)
"xtra p_t 4": XtraDB 1.0.4-new (4 purge threads)</pre>
<p>The graphs show...</p>
<ul>
<li>The purge thread (&gt; 0) helps to stabilize the throughput greatly.</li>
<li>Increasing the purge threads can suppress the strong growing of the hitory list</li>
<li>The adaptive checkpoint "estimate" needs the purge_thread... (than the adaptive_flushing does)</li>
</ul>
<p>And the last 300secs' average tps are...</p>
<pre>"Norm 1.0.4": 5725.47
"xtra p_t 0": 4699.33
"xtra p_t 1": 7130.3
"xtra p_t 4": 9118    (about 60%up from Normal Plugin 1.0.4)</pre>
<p>In the end, the faster and more stable performance of db_STRESS benchmark is obtained by these tunings of XtraDB.</p>
<p>-----------------------------------------</p>
<p>(Added 2009.10.29)</p>
<p>&lt;<strong>FAQ: Is XtraDB slower than Plugin?</strong>&gt;</p>
<p>I'd like to say <strong>"no"</strong> to this question. We have been adding many tuning options to XtraDB. But they are effective not for all cases, sometimes the performance may get worse because of "not proper" or "too much value". We should choose the options correctly. XtraDB is based on InnoDB Plugin and we can set XtraDB same to InnoDB Plugin at least. The following graphs are results of XtraDB and Plugin with same options and same database.</p>
<p>top-left (same condition to above graphs):<br />
innodb_flush_log_at_trx_commit = 2<br />
innodb_doublewrite = true</p>
<p>top-right:<br />
innodb_flush_log_at_trx_commit = 1<br />
innodb_doublewrite = true</p>
<p>bottom-left:<br />
innodb_flush_log_at_trx_commit = 2<br />
innodb_doublewrite = false</p>
<p>bottom-right:<br />
innodb_flush_log_at_trx_commit = 1<br />
innodb_doublewrite = false</p>
<p><img class="alignnone size-full wp-image-1570" title="purge_thread_test_2_TPS" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/10/purge_thread_test_2_TPS.png" alt="purge_thread_test_2_TPS" width="952" height="566" /></p>
<p>It seems that XtraDB is not slower than Plugin here at least.</p>
<p><strong><em>We can start tuning based on these performances using XtraDB specific options!</em></strong></p>
<p>Why do you make XtraDB slower than Plugin? <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Yasufumi |
      <a href="http://www.mysqlperformanceblog.com/2009/10/14/tuning-for-heavy-writing-workloads/#comments">9 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/10/14/tuning-for-heavy-writing-workloads/&amp;title=Tuning for heavy writing workloads" 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/2009/10/14/tuning-for-heavy-writing-workloads/&amp;title=Tuning for heavy writing workloads" 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/2009/10/14/tuning-for-heavy-writing-workloads/&amp;title=Tuning for heavy writing workloads" 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/2009/10/14/tuning-for-heavy-writing-workloads/&amp;T=Tuning for heavy writing workloads" 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/2009/10/14/tuning-for-heavy-writing-workloads/&amp;title=Tuning for heavy writing workloads" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/10/14/tuning-for-heavy-writing-workloads/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How number of columns affects performance ?</title>
		<link>http://www.mysqlperformanceblog.com/2009/09/28/how-number-of-columns-affects-performance/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/09/28/how-number-of-columns-affects-performance/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 01:39:04 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[benchmarks]]></category>
		<category><![CDATA[myisam]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1244</guid>
		<description><![CDATA[It is pretty understood the tables which have long rows tend to be slower than tables with short rows.   I was interested to check if the row length is the only thing what matters or if number of columns we have to work with also have an important role.    I [...]]]></description>
			<content:encoded><![CDATA[<p>It is pretty understood the tables which have long rows tend to be slower than tables with short rows.   I was interested to check if the row length is the only thing what matters or if number of columns we have to work with also have an important role.    I was interested in peak row processing speed so I looked at full table scan in case data fits in OS cache completely.   I created 3 tables -  First containing single tinyint column which is almost shortest type possible (CHAR(0) could be taking less space),  table with 1 tinyint column and char(99) column and table with 100 tinyint columns.    The former two tables have the same row length but have number of column different 50 times. Finally I have created 4th table which is also 100 columns but one of them is VARCHAR causes raw format to be dynamic.</p>
<p>More specially:</p>
<div class="igBar"><span id="lsql-31"><a href="#" onclick="javascript:showPlainTxt('sql-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-31">
<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;">`t1`</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;">`t1`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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></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:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lsql-32"><a href="#" onclick="javascript:showPlainTxt('sql-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-32">
<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;">`t1c99`</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;">`t1`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`c99`</span> char<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">99</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</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;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lsql-33"><a href="#" onclick="javascript:showPlainTxt('sql-33'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-33">
<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;">`t100`</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;">`t1`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`t2`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</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;">`t99`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`t100`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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></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:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lsql-34"><a href="#" onclick="javascript:showPlainTxt('sql-34'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-34">
<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;">`t99v1`</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;">`t1`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`t2`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</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;">`t99`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`v1`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</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:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I populated each of the tables with 12M rows. Getting  7 bytes row size for first table  and 101 byte for second and third.<br />
I used simple scan query: <strong>select max(t1) from t100;</strong>  for the test.</p>
<p>The result was as follows:<br />
t1            -   1.00 sec      (12M rows/sec  ;  80MB/sec)<br />
t1c99       -   1.71 sec      (7M rows/sec ;    676MB/sec)<br />
t100        -   1.77 sec      (7M rows/sec ;    653MB/sec)<br />
t99v1       -  12.36 sec      (1M rows/sec  ;   93MB/sec)</p>
<p>This shows there is surely the problem with dynamic row format table with many columns.   But is it because of large number of columns or dynamic format on its own is slave ?<br />
I have tested yet another table structure:</p>
<div class="igBar"><span id="lsql-35"><a href="#" onclick="javascript:showPlainTxt('sql-35'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-35">
<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;">`t1v1`</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;">`t1`</span> tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">3</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>,</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;">`v`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</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;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This table has row length of 20 (which was a bit of surprise to me) and it has:</p>
<p>t1v1           - 1.83 sec  (6.5M rows/sec;  125M/sec)</p>
<p>So there is surely the penalty for dynamic rows, however it is not very significant if number of columns is small.   For large number of columns dynamic rows become very expensive and you have to watch out.<br />
I have not looked at the code and would appreciate any developers comments but I guess for dynamic rows tables certain conversion has to take place when internal data structures are populated (everything but TEXTs/BLOBs  is fixed length when it is being processed).   This conversion process depends on number of columns while for fixed rows the MyISAM storage format matches internal one so you can basically do memory copy which does not depends on number of columns. </p>
<p>Another interesting observation  is access speed to different columns.    the max(t1) and max(t99) were taking the same time which means there is no penalty for accessing column which is in the end of the table rather than at the start when it comes to MyISAM.</p>
<p>The common workaround working with such wide tables is to use covering indexes.  I added one to t99v1 table  and repeated the query:</p>
<div class="igBar"><span id="lsql-36"><a href="#" onclick="javascript:showPlainTxt('sql-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-36">
<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;">mysql <span style="color:#006600; font-weight:bold;">&#91;</span>localhost<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>msandbox<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span style="color: #993333; font-weight: bold;">SELECT</span> max<span style="color:#006600; font-weight:bold;">&#40;</span>t1+<span style="color: #cc66cc;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> t99v1;</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;">-----------+</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;">| max<span style="color:#006600; font-weight:bold;">&#40;</span>t1+<span style="color: #cc66cc;color:#800000;">0</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: #808080; font-style: italic;">-----------+</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; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #cc66cc;color:#800000;">0</span> |</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;">-----------+</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;">1</span> row <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>.<span style="color: #cc66cc;color:#800000;">26</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 <span style="color:#006600; font-weight:bold;">&#91;</span>localhost<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>msandbox<span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#40;</span>test<span style="color:#006600; font-weight:bold;">&#41;</span>&gt; <span style="color: #993333; font-weight: bold;">EXPLAIN</span> <span style="color: #993333; font-weight: bold;">SELECT</span> max<span style="color:#006600; font-weight:bold;">&#40;</span>t1+<span style="color: #cc66cc;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span> t99v1;</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;">----+-------------+-------+-------+---------------+------+---------+------+----------+-------------+</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;">| id | select_type | <span style="color: #993333; font-weight: bold;">TABLE</span> | type&nbsp; | possible_keys | <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; | key_len | ref&nbsp; | rows&nbsp; &nbsp; &nbsp;| Extra&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;">----+-------------+-------+-------+---------------+------+---------+------+----------+-------------+</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: #cc66cc;color:#800000;">1</span> | SIMPLE&nbsp; &nbsp; &nbsp; | t99v1 | <span style="color: #993333; font-weight: bold;">INDEX</span> | <span style="color: #993333; font-weight: bold;">NULL</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | t1&nbsp; &nbsp;| <span style="color: #cc66cc;color:#800000;">1</span>&nbsp; &nbsp; &nbsp; &nbsp;| <span style="color: #993333; font-weight: bold;">NULL</span> | <span style="color: #cc66cc;color:#800000;">12000000</span> | <span style="color: #993333; font-weight: bold;">USING</span> <span style="color: #993333; font-weight: bold;">INDEX</span> |</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;">----+-------------+-------+-------+---------------+------+---------+------+----------+-------------+</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;">1</span> row <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;">00</span> sec<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As you can see the index scan is not as fast as table scan scanning about 3.7M rows/sec but which is still pretty fast. </p>
<p>So this is all about MyISAM, what is about Innodb ?  Here are results for Innodb with all data in buffer pool, to measure peak speed as well</p>
<p>The results for Innodb were:<br />
t1                          -    5.11 sec      (2.3M rows/sec)<br />
t1c99                     -    5.74 sec      (2.1M rows/sec)<br />
t100                       -   15.16 sec     (0.8M rows/sec)<br />
t99v1                      -  14.93 sec      (0.8M rows/sec)<br />
t1v1                        -  5.26 sec       (2.3M rows/sec)<br />
t99v1 (covering idx)   -  5.62 sec       (2.1M rows/sec)</p>
<p>As you can see Innodb is a lot slower and has behavior similar to Dynamic Row tables in both cases.  This is because Innodb does not store data in native MyISAM format and conversion is needed in all cases. We can also see the table scan speed can be up to 5 times slower, for very short rows - some of this goes back to the fact Innodb rows have a lot of transaction control overhead attached to them.</p>
<p>Also note the covering index scan speed is very similar to full table scan speed - this is rather expected as table data is stored in BTREE index  very similarly to how indexes are stored. </p>
<p><strong>Summary:</strong>  Beware of dynamic row format tables with many columns they might bite you with surprise slowdown.   MyISAM is much faster than Innodb when it comes to in memory full table scan. </p>
<p>P.S Tests were done on MySQL 5.4.2  on Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz CPU. </p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by peter |
      <a href="http://www.mysqlperformanceblog.com/2009/09/28/how-number-of-columns-affects-performance/#comments">9 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/09/28/how-number-of-columns-affects-performance/&amp;title=How number of columns affects performance ?" 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/2009/09/28/how-number-of-columns-affects-performance/&amp;title=How number of columns affects performance ?" 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/2009/09/28/how-number-of-columns-affects-performance/&amp;title=How number of columns affects performance ?" 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/2009/09/28/how-number-of-columns-affects-performance/&amp;T=How number of columns affects performance ?" 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/2009/09/28/how-number-of-columns-affects-performance/&amp;title=How number of columns affects performance ?" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/09/28/how-number-of-columns-affects-performance/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Why InnoDB index cardinality varies strangely</title>
		<link>http://www.mysqlperformanceblog.com/2009/09/28/why-innodb-index-cardinality-varies-strangely/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/09/28/why-innodb-index-cardinality-varies-strangely/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 13:06:08 +0000</pubDate>
		<dc:creator>Baron Schwartz</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=386</guid>
		<description><![CDATA[This is a very old draft, from early 2007 in fact.  At that time I started to look into something interesting with the index cardinality statistics reported by InnoDB tables.  The cardinality varies because it's derived from estimates, and I know a decent amount about that.  The interesting thing I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very old draft, from early 2007 in fact.  At that time I started to look into something interesting with the index cardinality statistics reported by InnoDB tables.  The cardinality varies because it's derived from estimates, and I know a decent amount about that.  The interesting thing I wanted to look into was why the cardinality varies in a particular pattern.</p>
<p>Here I'll grab a bunch of cardinality estimates from sakila.film on MySQL 5.0.45 and put them into a file:</p>
<div class="igBar"><span id="lcode-39"><a href="#" onclick="javascript:showPlainTxt('code-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-39">
<div class="code">
<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;">baron@kanga:~$ while true; do mysql sakila -N -e <span style="color:#CC0000;">'show index from film'</span> | head -n <span style="color:#800000;color:#800000;">2</span> | tail -n <span style="color:#800000;color:#800000;">1</span> | awk <span style="color:#CC0000;">'{print $7}'</span>; done&gt; sizes </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>After a while I cancel it and then sort and aggregate them with counts:</p>
<div class="igBar"><span id="lcode-40"><a href="#" onclick="javascript:showPlainTxt('code-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-40">
<div class="code">
<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;">baron@kanga:~$ sort sizes | uniq -c</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">157</span> <span style="color:#800000;color:#800000;">1022</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:#800000;color:#800000;">156</span> <span style="color:#800000;color:#800000;">1024</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">156</span> <span style="color:#800000;color:#800000;">1058</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:#800000;color:#800000;">156</span> <span style="color:#800000;color:#800000;">1059</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">156</span> <span style="color:#800000;color:#800000;">1131</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:#800000;color:#800000;">313</span> <span style="color:#800000;color:#800000;">951</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">312</span> <span style="color:#800000;color:#800000;">952</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:#800000;color:#800000;">312</span> <span style="color:#800000;color:#800000;">953</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Look at the distribution of the counts.  The weighted average of these is 1000.53, so it's close to the truth (1000 rows).  But five of the eight distinct estimates are shown about one-half as often as the others; it looks like the random choice of which statistic to use is not evenly distributed.</p>
<p>I mentioned this to Heikki and he pondered it for a bit -- but neither of us really figured out what was going on.  I know the code superficially, but not as well as he or Yasufumi or others do; and I was not able to find a cause.</p>
<p>More recently I saw that <a href="http://blogs.innodb.com/wp/2009/04/only-god-can-make-random-selections/">I'm not the only one who notices oddities in the random number generation</a>.  I waited.  And indeed the fixes for that bug seemed to have fixed the skew in the statistics.  Case solved, and all I had to do was wait.  Truly, laziness is a virtue.</p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Baron Schwartz |
      <a href="http://www.mysqlperformanceblog.com/2009/09/28/why-innodb-index-cardinality-varies-strangely/#comments">5 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/09/28/why-innodb-index-cardinality-varies-strangely/&amp;title=Why InnoDB index cardinality varies strangely" 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/2009/09/28/why-innodb-index-cardinality-varies-strangely/&amp;title=Why InnoDB index cardinality varies strangely" 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/2009/09/28/why-innodb-index-cardinality-varies-strangely/&amp;title=Why InnoDB index cardinality varies strangely" 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/2009/09/28/why-innodb-index-cardinality-varies-strangely/&amp;T=Why InnoDB index cardinality varies strangely" 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/2009/09/28/why-innodb-index-cardinality-varies-strangely/&amp;title=Why InnoDB index cardinality varies strangely" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/09/28/why-innodb-index-cardinality-varies-strangely/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Which adaptive should we use?</title>
		<link>http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 00:12:44 +0000</pubDate>
		<dc:creator>Yasufumi</dc:creator>
				<category><![CDATA[Innodb]]></category>
		<category><![CDATA[benchmarks]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tuning]]></category>
		<category><![CDATA[xtradb]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1125</guid>
		<description><![CDATA[As you may know, InnoDB has 2 limits for unflushed modified blocks in the buffer pool. The one is from physical size of the buffer pool. And the another one is oldness of the block which is from the capacity of transaction log files.
In the case of heavy updating workload, the modified ages of the [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know, InnoDB has 2 limits for unflushed modified blocks in the buffer pool. The one is from physical size of the buffer pool. And the another one is oldness of the block which is from the capacity of transaction log files.</p>
<p>In the case of heavy updating workload, the modified ages of the many blocks are clustered. And to reduce the maximum of the modified ages InnoDB needs to flush many of the blocks in a short time, if these are not flushed at all. Then the flushing storm affect the performance seriously.</p>
<p>We suggested the "adaptive_checkpoint" option of constant flushing to avoid such a flushing storm. And finally, the newest InnoDB Plugin 1.0.4 has the new similar option "adaptive_flushing" as native.</p>
<p>Let's check the adaptive flushing options at this post.</p>
<p><em><strong>HOW THEY WORK</strong></em></p>
<p><strong>&lt; adaptive_checkpoint=reflex (older method)&gt;</strong></p>
<table border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td>oldest modified age %/max</td>
<td>behavior</td>
</tr>
<tr>
<td>0 ~ 50%</td>
<td>nothing</td>
</tr>
<tr>
<td>50% ~ 75%</td>
<td>constant flushing (weak)</td>
</tr>
<tr>
<td>75% ~ 87.5%</td>
<td>constant flushing (strong)</td>
</tr>
<tr>
<td>87.5% ~</td>
<td>(flushing storm)</td>
</tr>
</tbody>
</table>
<p><strong>&lt; adaptive_checkpoint=estimate (newer method)&gt;</strong></p>
<table border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td>oldest modified age %/max</td>
<td>behavior</td>
</tr>
<tr>
<td>0 ~ 50%</td>
<td>nothing</td>
</tr>
<tr>
<td>50% ~ 87.5%</td>
<td>estimate flushing as bellow *</td>
</tr>
<tr>
<td>87.5% ~</td>
<td>(flushing storm)</td>
</tr>
</tbody>
</table>
<p>* estimate blocks to flush based on...</p>
<ul>
<li> how many modified and unflushed blocks</li>
<li> progress speed of the transaction log</li>
<li> the modified age average of all blocks to flush</li>
</ul>
<p><strong>&lt; adaptive_flushing (default "true" at 1.0.4)&gt;</strong><br />
Its behavior is not based on the oldest modified age %.</p>
<p>* the how many blocks to flush based on...</p>
<ul>
<li> how many modified and unflushed blocks</li>
<li> progress speed of the transaction log</li>
<li> transaction log capacity</li>
</ul>
<p>(and adjust along with another flushing)</p>
<p>And it doesn't exceed the equivalent to "constant flushing (strong)"<br />
of the "adaptive_checkpoint=reflex"</p>
<p><em><strong>RESULTS</strong></em></p>
<p>TPC-C like workload (100WH: 16 session full)</p>
<p>innodb_buffer_pool_size = 16G<br />
innodb_max_dirty_pages_pct = 90</p>
<p>innodb_log_file_size = 512M<br />
innodb_log_files_in_group = 2</p>
<p>innodb_io_capacity = 4000<br />
innodb_read_io_threads = 8<br />
innodb_write_io_threads = 8<br />
innodb_flush_method = O_DIRECT</p>
<p>innodb_thread_concurrency = 0<br />
innodb_ibuf_active_contract = 1</p>
<p><strong>&lt;none&gt;</strong><br />
innodb_adaptive_flushing = false<br />
innodb_adaptive_checkpoint = none</p>
<p><strong>&lt;flushing&gt;</strong><br />
innodb_adaptive_flushing = true</p>
<p><strong>&lt;reflex&gt;</strong><br />
innodb_adaptive_flushing = false<br />
innodb_adaptive_checkpoint = reflex</p>
<p><strong>&lt;estimate&gt;</strong><br />
innodb_adaptive_flushing = false<br />
innodb_adaptive_checkpoint = estimate</p>
<p><strong><em>case1: "innodb_doublewrite = false"</em></strong></p>
<p>[0~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1132" title="no_doublewrite-0-1800" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/no_doublewrite-0-18001.png" alt="no_doublewrite-0-1800" width="705" height="388" /></p>
<p>[1200~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1134" title="no_doublewrite-1200-1800" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/no_doublewrite-1200-1800.png" alt="no_doublewrite-1200-1800" width="705" height="388" /></p>
<p>averages (1200~1800 sec.)<br />
none:     6868.92<br />
flushing: 6655.92<br />
reflex:     6481<br />
estimate: 6575.88</p>
<p><strong><em>case2: "innodb_doublewrite = true"</em></strong></p>
<p>[0~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1137" title="doublewrite-0-1800" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/doublewrite-0-1800.png" alt="doublewrite-0-1800" width="705" height="388" /></p>
<p>[1200~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1138" title="doublewrite-1200-1800" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/doublewrite-1200-1800.png" alt="doublewrite-1200-1800" width="705" height="388" /></p>
<p>averages (1200~1800 sec.)<br />
none:     6569.48<br />
flushing: 5090.12<br />
reflex:     6871.9<br />
estimate: 6609.9</p>
<p><strong><em>CONSIDERINGS</em></strong></p>
<p>The new "adaptive_flushing" seems to be tuned for "innodb_doublewrite = false" only.<br />
(cause too much flushing for "innodb_doublewrite = true")</p>
<p>"innodb_adaptive_checkpoint = reflex" and "adaptive_flushing" need tuning innodb_io_capacity properly.<br />
(The result is based on proper value "innodb_io_capacity = 4000")</p>
<p>"innodb_adaptive_checkpoint = estimate" is not depend on innodb_io_capacity, and it seems more "soft" result than the other methods.</p>
<p>So,</p>
<p>The "adaptive_flushing" seems good when we use "innodb_doublewrite = false".</p>
<p>"innodb_adaptive_checkpoint = estimate" may be safe for "innodb_doublewrite = true" for now.</p>
<p>I should adjust "adaptive_flushing" for "innodb_doublewrite = true". <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<hr /><em><strong>IMPROVEMENTS</strong></em> (16 Sep.)</p>
<p>I have tried to improve the performance. But I couldn't adjust performance of adaptive_flushing with doublewrite... So, instead of that, estimate is adjusted more.</p>
<p><strong><em>case1: "innodb_doublewrite = false"</em></strong></p>
<p>[0~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1159" title="no_doublewrite-0-1800_2" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/no_doublewrite-0-1800_21.png" alt="no_doublewrite-0-1800_2" width="705" height="388" /></p>
<p><strong><em>case2: "innodb_doublewrite = true"</em></strong></p>
<p>[0~1800 sec.]</p>
<p><img class="alignnone size-full wp-image-1160" title="doublewrite-0-1800_2" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/doublewrite-0-1800_2.png" alt="doublewrite-0-1800_2" width="705" height="388" /></p>
<p>The new "innodb_adaptive_checkpoint = estimate" seems to be more stable than before. The next question is, <strong>"Why is estimate + doublewrite better than the other no doublewrite settings?"</strong>... <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<hr /><strong>ADDITIONAL TEST IN ANOTHER BALANCE</strong></p>
<p>Also tested in another configuration to check the behaviors in another balance of IO bound.</p>
<p>&lt;changes&gt;<br />
innodb_buffer_pool_size = 2G   (1/8)<br />
innodb_log_file_size = 128M    (1/4)</p>
<p><strong><em>case1: "innodb_doublewrite = false"</em></strong></p>
<p>[0~1200 sec.]</p>
<p><img class="alignnone size-full wp-image-1202" title="no_doublewrite_2-0-1200" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/no_doublewrite_2-0-1200.png" alt="no_doublewrite_2-0-1200" width="705" height="387" /></p>
<p><strong><em>case2: "innodb_doublewrite = true"</em></strong></p>
<p>[0~1200 sec.]</p>
<p><img class="alignnone size-full wp-image-1203" title="doublewrite_2-0-1200" src="http://www.mysqlperformanceblog.com/wp-content/uploads/2009/09/doublewrite_2-0-1200.png" alt="doublewrite_2-0-1200" width="705" height="387" /></p>
<p>"innodb_adaptive_checkpoint = estimate" seems stable but seems to flush much in its initial phase. The adaptive_flushing seems to be more soft in this cases.</p>
<p>Hmmm....</p>
<p><strong>We should choose suitable adaptive_xxx for each workload for now</strong>... <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Yasufumi |
      <a href="http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/#comments">12 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/&amp;title=Which adaptive should we use?" 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/2009/09/15/which-adaptive-should-we-use/&amp;title=Which adaptive should we use?" 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/2009/09/15/which-adaptive-should-we-use/&amp;title=Which adaptive should we use?" 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/2009/09/15/which-adaptive-should-we-use/&amp;T=Which adaptive should we use?" 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/2009/09/15/which-adaptive-should-we-use/&amp;title=Which adaptive should we use?" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/09/15/which-adaptive-should-we-use/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Queries Active vs Transactions Active</title>
		<link>http://www.mysqlperformanceblog.com/2009/09/14/queries-active-vs-transactions-active/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/09/14/queries-active-vs-transactions-active/#comments</comments>
		<pubDate>Tue, 15 Sep 2009 02:50:19 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Innodb]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1113</guid>
		<description><![CDATA[What is wrong here (the part of SHOW INNODB STATUS):

--------------
ROW OPERATIONS
--------------
8 queries inside InnoDB, 9 queries in queue
100 read views open inside InnoDB

It is relationship between queries active - queries inside innodb+queries in the queue  totalling 17 with  "read views open inside InnoDB" which is a fancy way of saying "active transactions" which [...]]]></description>
			<content:encoded><![CDATA[<p>What is wrong here (the part of SHOW INNODB STATUS):</p>
<blockquote><p>
--------------<br />
ROW OPERATIONS<br />
--------------<br />
8 queries inside InnoDB, 9 queries in queue<br />
100 read views open inside InnoDB
</p></blockquote>
<p>It is relationship between queries active - queries inside innodb+queries in the queue  totalling 17 with  "read views open inside InnoDB" which is a fancy way of saying "active transactions" which is 100.</p>
<p>Typically you would want this ratio to be close to 1, may be 2  which would correspond all active transactions doing active work and spending little time waiting on the application.   Waiting transactions are bad because they hold lock as well as other resources, such as preventing innodb purge operation from proceeding.</p>
<p>If you see something like this in your envinronment it often makes sense to check the the list of transactions too.  Chances are you would see something like:</p>
<blockquote><p>
---TRANSACTION 0 1044183147, ACTIVE 963 sec, process no 27713, OS thread id 1227987264 waiting in InnoDB queue
</p></blockquote>
<p>which corresponds to transaction active for over 15 minutes. </p>
<p>Sometimes you would see some query associated with such transactions showing up often in the processlist, which often corresponds to some long batch jobs,  sometimes you would just see the processlist showing connection is in "Sleep" mode for a long time which means application is holding transaction open while waiting for something else.  Most of such situations are bugs either in application itself or connection pooling software. </p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by peter |
      <a href="http://www.mysqlperformanceblog.com/2009/09/14/queries-active-vs-transactions-active/#comments">No comment</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/09/14/queries-active-vs-transactions-active/&amp;title=Queries Active vs Transactions Active" 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/2009/09/14/queries-active-vs-transactions-active/&amp;title=Queries Active vs Transactions Active" 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/2009/09/14/queries-active-vs-transactions-active/&amp;title=Queries Active vs Transactions Active" 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/2009/09/14/queries-active-vs-transactions-active/&amp;T=Queries Active vs Transactions Active" 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/2009/09/14/queries-active-vs-transactions-active/&amp;title=Queries Active vs Transactions Active" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/09/14/queries-active-vs-transactions-active/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Statistics of InnoDB tables and indexes available in xtrabackup</title>
		<link>http://www.mysqlperformanceblog.com/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/</link>
		<comments>http://www.mysqlperformanceblog.com/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 16:52:53 +0000</pubDate>
		<dc:creator>Vadim</dc:creator>
				<category><![CDATA[Backups]]></category>
		<category><![CDATA[Innodb]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=1095</guid>
		<description><![CDATA[If you ever wondered how big is that or another index in InnoDB ... you had to calculate it yourself by multiplying size of row (which I should add is harder in the case of a VARCHAR - since you need to estimate average length) on count of records. And it still would be quite [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever wondered how big is that or another index in InnoDB ... you had to calculate it yourself by multiplying size of row (which I should add is harder in the case of a VARCHAR - since you need to estimate average length) on count of records. And it still would be quite inaccurate as secondary indexes  tend to take more space. So we added more detailed index statistics into our xtrabackup utility.  The thanks for this feature goes to a well known Social Network who sponsored the development.</p>
<p>We chose to put this into xtrabackup for a couple of reasons - the first is that running statistics on your backup database does not need to hurt production servers, and the second reason is that running statistic on a stopped database is more accurate than with online (although online is also supported, but you may have inexact results).</p>
<p>Let's see how it works. I have one table with size 13Gb what was filled during about 2.5 years.<br />
The table is:</p>
<div class="igBar"><span id="lcode-46"><a href="#" onclick="javascript:showPlainTxt('code-46'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-46">
<div class="code">
<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;">CREATE TABLE `link_out104` <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; `domain_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</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; `link_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL auto_increment,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `url_from` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</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; `url_to` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `anchor` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</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; `from_site_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `from_forum_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</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; `from_author_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `from_message_id` bigint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">20</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</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; `message_published` timestamp NOT NULL default CURRENT_TIMESTAMP,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `kind` enum<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'link'</span>,<span style="color:#CC0000;">'img'</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</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; `url_title` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `isexternal` tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</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; `revert_domain` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `url_prefix` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">255</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</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; `from_domain_id` int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `ext` varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">25</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</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; `linktype` enum<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'html'</span>,<span style="color:#CC0000;">'video'</span>,<span style="color:#CC0000;">'mp3'</span>,<span style="color:#CC0000;">'image'</span>,<span style="color:#CC0000;">'pdf'</span>,<span style="color:#CC0000;">'other'</span><span style="color:#006600; font-weight:bold;">&#41;</span> NOT NULL,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `message_day` date NOT NULL,</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; `mod_is` tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL default <span style="color:#CC0000;">'0'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; `is_adult` tinyint<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> unsigned NOT NULL default <span style="color:#CC0000;">'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; PRIMARY KEY&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span>`link_id`<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; UNIQUE KEY `domain_id_2` <span style="color:#006600; font-weight:bold;">&#40;</span>`domain_id`,`link_id`<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; KEY `domain_id` <span style="color:#006600; font-weight:bold;">&#40;</span>`domain_id`,`from_site_id`,`message_published`<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; KEY `revert_domain` <span style="color:#006600; font-weight:bold;">&#40;</span>`revert_domain`,`url_prefix`<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">80</span><span style="color:#006600; font-weight:bold;">&#41;</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; KEY `from_site_id` <span style="color:#006600; font-weight:bold;">&#40;</span>`from_site_id`,`message_published`<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; KEY `site_message` <span style="color:#006600; font-weight:bold;">&#40;</span>`from_site_id`,`message_day`,`isexternal`<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; KEY `from_message_id` <span style="color:#006600; font-weight:bold;">&#40;</span>`from_message_id`,`link_id`<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 AUTO_INCREMENT=<span style="color:#800000;color:#800000;">26141165</span> DEFAULT CHARSET=utf8; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And size of file is about 12.88 GB<br />
<code><br />
-rw-r--r-- 1 root root 13832814592 Sep 10 14:41 link_out104.ibd<br />
</code></p>
<p>So to get statistics we run:</p>
<p><code>xtrabackup --stats --tables=art.link* --datadir=/mnt/data/mysql/</code></p>
<p>which will show something like this:</p>
<div class="igBar"><span id="lcode-47"><a href="#" onclick="javascript:showPlainTxt('code-47'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-47">
<div class="code">
<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;">&lt;INDEX STATISTICS&gt;</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;">&nbsp; table: art/link_out104, index: PRIMARY, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">3</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; estimated statistics in dictionary:</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; &nbsp; key vals: <span style="color:#800000;color:#800000;">25265338</span>, leaf pages <span style="color:#800000;color:#800000;">497839</span>, size pages <span style="color:#800000;color:#800000;">498304</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; real statistics:</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">5395</span> bytes, data/pages=<span style="color:#800000;color:#800000;">32</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">415</span>, data=<span style="color:#800000;color:#800000;">6471907</span> bytes, data/pages=<span style="color:#800000;color:#800000;">95</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; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25958413</span>, pages=<span style="color:#800000;color:#800000;">497839</span>, data=<span style="color:#800000;color:#800000;">7492026403</span> bytes, data/pages=<span style="color:#800000;color:#800000;">91</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;">&nbsp; table: art/link_out104, index: domain_id_2, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">4</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; estimated statistics in dictionary:</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; &nbsp; key vals: <span style="color:#800000;color:#800000;">27755790</span>, leaf pages <span style="color:#800000;color:#800000;">23125</span>, size pages <span style="color:#800000;color:#800000;">26495</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; real statistics:</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">510</span> bytes, data/pages=<span style="color:#800000;color:#800000;">3</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">30</span>, data=<span style="color:#800000;color:#800000;">393125</span> bytes, data/pages=<span style="color:#800000;color:#800000;">79</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; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25958413</span>, pages=<span style="color:#800000;color:#800000;">23125</span>, data=<span style="color:#800000;color:#800000;">337459369</span> bytes, data/pages=<span style="color:#800000;color:#800000;">89</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;">&nbsp; table: art/link_out104, index: domain_id, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">5</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; estimated statistics in dictionary:</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; &nbsp; key vals: <span style="color:#800000;color:#800000;">3006231</span>, leaf pages <span style="color:#800000;color:#800000;">43255</span>, size pages <span style="color:#800000;color:#800000;">49600</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; real statistics:</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">2850</span> bytes, data/pages=<span style="color:#800000;color:#800000;">17</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">114</span>, data=<span style="color:#800000;color:#800000;">1081375</span> bytes, data/pages=<span style="color:#800000;color:#800000;">57</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; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25953873</span>, pages=<span style="color:#800000;color:#800000;">43255</span>, data=<span style="color:#800000;color:#800000;">545031333</span> bytes, data/pages=<span style="color:#800000;color:#800000;">76</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;">&nbsp; table: art/link_out104, index: revert_domain, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">6</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; estimated statistics in dictionary:</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; &nbsp; key vals: <span style="color:#800000;color:#800000;">1204830</span>, leaf pages <span style="color:#800000;color:#800000;">133869</span>, size pages <span style="color:#800000;color:#800000;">153984</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; real statistics:</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">3</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">373</span> bytes, data/pages=<span style="color:#800000;color:#800000;">2</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">6</span>, data=<span style="color:#800000;color:#800000;">58143</span> bytes, data/pages=<span style="color:#800000;color:#800000;">59</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">832</span>, data=<span style="color:#800000;color:#800000;">9146283</span> bytes, data/pages=<span style="color:#800000;color:#800000;">67</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25839414</span>, pages=<span style="color:#800000;color:#800000;">133869</span>, data=<span style="color:#800000;color:#800000;">1566961607</span> bytes, data/pages=<span style="color:#800000;color:#800000;">71</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;">&nbsp; table: art/link_out104, index: from_site_id, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">7</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; estimated statistics in dictionary:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; key vals: <span style="color:#800000;color:#800000;">330426</span>, leaf pages <span style="color:#800000;color:#800000;">33889</span>, size pages <span style="color:#800000;color:#800000;">38848</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; real statistics:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">1764</span> bytes, data/pages=<span style="color:#800000;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;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">84</span>, data=<span style="color:#800000;color:#800000;">711669</span> bytes, data/pages=<span style="color:#800000;color:#800000;">51</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25956416</span>, pages=<span style="color:#800000;color:#800000;">33889</span>, data=<span style="color:#800000;color:#800000;">441259072</span> bytes, data/pages=<span style="color:#800000;color:#800000;">79</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;">&nbsp; table: art/link_out104, index: site_message, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">8</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; estimated statistics in dictionary:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; key vals: <span style="color:#800000;color:#800000;">1399286</span>, leaf pages <span style="color:#800000;color:#800000;">32260</span>, size pages <span style="color:#800000;color:#800000;">36992</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; real statistics:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">1680</span> bytes, data/pages=<span style="color:#800000;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;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">80</span>, data=<span style="color:#800000;color:#800000;">677460</span> bytes, data/pages=<span style="color:#800000;color:#800000;">51</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25956043</span>, pages=<span style="color:#800000;color:#800000;">32260</span>, data=<span style="color:#800000;color:#800000;">441252731</span> bytes, data/pages=<span style="color:#800000;color:#800000;">83</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;">&nbsp; table: art/link_out104, index: from_message_id, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">9</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; estimated statistics in dictionary:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; key vals: <span style="color:#800000;color:#800000;">25964521</span>, leaf pages <span style="color:#800000;color:#800000;">27979</span>, size pages <span style="color:#800000;color:#800000;">28160</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; real statistics:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">798</span> bytes, data/pages=<span style="color:#800000;color:#800000;">4</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">38</span>, data=<span style="color:#800000;color:#800000;">587559</span> bytes, data/pages=<span style="color:#800000;color:#800000;">94</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25958413</span>, pages=<span style="color:#800000;color:#800000;">27979</span>, data=<span style="color:#800000;color:#800000;">441293021</span> bytes, data/pages=<span style="color:#800000;color:#800000;">96</span>% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The output is  intensive, let me highlight some points:</p>
<div class="igBar"><span id="lcode-48"><a href="#" onclick="javascript:showPlainTxt('code-48'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-48">
<div class="code">
<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;">table: art/link_out104, index: PRIMARY, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">3</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25958413</span>, pages=<span style="color:#800000;color:#800000;">497839</span>, data=<span style="color:#800000;color:#800000;">7492026403</span> bytes, data/pages=<span style="color:#800000;color:#800000;">91</span>% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It says that PRIMARY key (which is the table by itself, as InnoDB is clustering data by primary key) takes <strong>497839</strong> pages ( 16KB each) and size of data <strong>7492026403</strong> bytes or (6.98 GB). And density ( fitting data into pages) is quite good - 91%. But it was expected, as table is really mostly inserted in, updates and deletes are rare).</p>
<p>And let's take index <strong>domain_id</strong></p>
<div class="igBar"><span id="lcode-49"><a href="#" onclick="javascript:showPlainTxt('code-49'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-49">
<div class="code">
<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;">table: art/link_out104, index: domain_id, space id: <span style="color:#800000;color:#800000;">12</span>, root page <span style="color:#800000;color:#800000;">5</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25953873</span>, pages=<span style="color:#800000;color:#800000;">43255</span>, data=<span style="color:#800000;color:#800000;">545031333</span> bytes, data/pages=<span style="color:#800000;color:#800000;">76</span>% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>you can see the allocated pages (43255 pages or 708689920 bytes) are filled only by 76% ( data takes 545031333 bytes). And that means that 150MB are just waste of space. Which is really even worse for key <strong>revert_domain</strong></p>
<p><code>   leaf pages: recs=25839414, pages=133869, data=1566961607 bytes, data/pages=71%<br />
</code>.</p>
<p>For this key about 600MB is empty. </p>
<p>This needs a bit of explaining:<br />
This does not have as good efficiency as the primary key, but a lot of this is to be expected.  In a lot of cases we insert into the primary key in order which makes things very predictable, but the inserts into the secondary key index are random - which leads to a lot of page splits.</p>
<p>One helpful new feature to address this is in XtraDB/InnoDB plugin - fast index creation.  With this feature, InnoDB creates indexes by sort, so page fill factor should be quite good.</p>
<p>To check that, there is xtrabackup --stats for index  <strong>domain_id</strong> created for table in Barracuda format with Fast creation method:</p>
<div class="igBar"><span id="lcode-50"><a href="#" onclick="javascript:showPlainTxt('code-50'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-50">
<div class="code">
<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;">table: art/link_out104, index: domain_id, space id: <span style="color:#800000;color:#800000;">15</span>, root page <span style="color:#800000;color:#800000;">49160</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; estimated statistics in dictionary:</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; &nbsp; key vals: <span style="color:#800000;color:#800000;">5750565</span>, leaf pages <span style="color:#800000;color:#800000;">34383</span>, size pages <span style="color:#800000;color:#800000;">34496</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; real statistics:</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; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">2</span> pages: pages=<span style="color:#800000;color:#800000;">1</span>, data=<span style="color:#800000;color:#800000;">1375</span> bytes, data/pages=<span style="color:#800000;color:#800000;">8</span>%</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;level <span style="color:#800000;color:#800000;">1</span> pages: pages=<span style="color:#800000;color:#800000;">55</span>, data=<span style="color:#800000;color:#800000;">859575</span> bytes, data/pages=<span style="color:#800000;color:#800000;">95</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; &nbsp; &nbsp; &nbsp; leaf pages: recs=<span style="color:#800000;color:#800000;">25958413</span>, pages=<span style="color:#800000;color:#800000;">34383</span>, data=<span style="color:#800000;color:#800000;">545126673</span> bytes, data/pages=<span style="color:#800000;color:#800000;">96</span>% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>As you see this time it takes 34383 pages (compare to 43255 in previous statistics).</p>
<p>Though it would be interesting to see how it will grow with further inserts, and I also suspect random INSERTS into so dense space going to be slower than in previous case.</p>
<p>The --stats is not in xtrabackup release yet, only in source code repository, but should be released quite soon.</p>
<p>And the last point of the post - if you are badly missing some features in MySQL, InnoDB, InnoDB-plugin, XtraDB, XtraBackup - you know whom ask for!</p>
    <hr noshade style="margin:0;height:1px" />
    <p>Entry posted by Vadim |
      <a href="http://www.mysqlperformanceblog.com/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/#comments">5 comments</a></p>
    <p>Add to: <a href="http://del.icio.us/post?url=http://www.mysqlperformanceblog.com/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/&amp;title=Statistics of InnoDB tables and indexes available in xtrabackup" 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/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/&amp;title=Statistics of InnoDB tables and indexes available in xtrabackup" 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/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/&amp;title=Statistics of InnoDB tables and indexes available in xtrabackup" 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/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/&amp;T=Statistics of InnoDB tables and indexes available in xtrabackup" 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/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/&amp;title=Statistics of InnoDB tables and indexes available in xtrabackup" 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>]]></content:encoded>
			<wfw:commentRss>http://www.mysqlperformanceblog.com/2009/09/14/statistics-of-innodb-tables-and-indexes-available-in-xtrabackup/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
