<?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>Gary Pendergast &#187; regression</title> <atom:link href="http://pento.net/tag/regression/feed/" rel="self" type="application/rss+xml" /><link>http://pento.net</link> <description>I&#039;m on the Internet</description> <lastBuildDate>Sat, 03 Dec 2011 09:27:46 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <cloud
domain='pento.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' /> <item><title>Don&#8217;t put a NULL in the IN clause in 5.1</title><link>http://pento.net/2009/04/08/dont-put-a-null-in-the-in-clause-in-51/</link> <comments>http://pento.net/2009/04/08/dont-put-a-null-in-the-in-clause-in-51/#comments</comments> <pubDate>Wed, 08 Apr 2009 07:36:08 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[MySQL 5.1]]></category> <category><![CDATA[optimizer]]></category> <category><![CDATA[regression]]></category> <guid
isPermaLink="false">http://pento.net/?p=173</guid> <description><![CDATA[There seems to be an optimizer problem in 5.1, if you put a NULL in the IN clause of a SELECT. For example, given the following table: CREATE TABLE foo &#40; a INT NOT NULL AUTO_INCREMENT, PRIMARY KEY &#40;a&#41; &#41;; Compare these two EXPLAINs: mysql&#62; EXPLAIN * FROM foo WHERE a IN &#40;160000, 160001, 160002&#41;\G [...]]]></description> <content:encoded><![CDATA[<p>There seems to be an optimizer problem in 5.1, if you put a NULL in the IN clause of a SELECT. For example, given the following table:</p><div
class="wp_syntax"><div
class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> foo <span style="color: #FF00FF;">&#40;</span>
    a <span style="color: #999900; font-weight: bold;">INT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #000033;">,</span>
    <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #FF00FF;">&#40;</span>a<span style="color: #FF00FF;">&#41;</span>
<span style="color: #FF00FF;">&#41;</span><span style="color: #000033;">;</span></pre></div></div><p>Compare these two EXPLAINs:</p><div
class="wp_syntax"><div
class="code"><pre class="mysql" style="font-family:monospace;">mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">EXPLAIN</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> foo <span style="color: #990099; font-weight: bold;">WHERE</span> a <span style="color: #990099; font-weight: bold;">IN</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">160000</span><span style="color: #000033;">,</span> <span style="color: #008080;">160001</span><span style="color: #000033;">,</span> <span style="color: #008080;">160002</span><span style="color: #FF00FF;">&#41;</span>\G
<span style="color: #CC0099;">***************************</span> <span style="color: #008080;">1</span>. row <span style="color: #CC0099;">***************************</span>
           id: <span style="color: #008080;">1</span>
  select_type: <span style="color: #990099; font-weight: bold;">SIMPLE</span>
        <span style="color: #990099; font-weight: bold;">table</span>: foo
         <span style="color: #990099; font-weight: bold;">type</span>: range
possible_keys: PRIMARY
          <span style="color: #990099; font-weight: bold;">key</span>: PRIMARY
      key_len: <span style="color: #008080;">4</span>
          ref: <span style="color: #9900FF; font-weight: bold;">NULL</span>
         rows: <span style="color: #008080;">3</span>
        Extra: <span style="color: #990099; font-weight: bold;">Using</span> <span style="color: #990099; font-weight: bold;">where</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.06</span> sec<span style="color: #FF00FF;">&#41;</span>
&nbsp;
mysql<span style="color: #CC0099;">&gt;</span> <span style="color: #990099; font-weight: bold;">EXPLAIN</span> <span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> foo <span style="color: #990099; font-weight: bold;">WHERE</span> a <span style="color: #990099; font-weight: bold;">IN</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #9900FF; font-weight: bold;">NULL</span><span style="color: #000033;">,</span> <span style="color: #008080;">160000</span><span style="color: #000033;">,</span> <span style="color: #008080;">160001</span><span style="color: #000033;">,</span> <span style="color: #008080;">160002</span><span style="color: #FF00FF;">&#41;</span>\G
<span style="color: #CC0099;">***************************</span> <span style="color: #008080;">1</span>. row <span style="color: #CC0099;">***************************</span>
           id: <span style="color: #008080;">1</span>
  select_type: <span style="color: #990099; font-weight: bold;">SIMPLE</span>
        <span style="color: #990099; font-weight: bold;">table</span>: foo
         <span style="color: #990099; font-weight: bold;">type</span>: <span style="color: #990099; font-weight: bold;">ALL</span>
possible_keys: PRIMARY
          <span style="color: #990099; font-weight: bold;">key</span>: <span style="color: #9900FF; font-weight: bold;">NULL</span>
      key_len: <span style="color: #9900FF; font-weight: bold;">NULL</span>
          ref: <span style="color: #9900FF; font-weight: bold;">NULL</span>
         rows: <span style="color: #008080;">327680</span>
        Extra: <span style="color: #990099; font-weight: bold;">Using</span> <span style="color: #990099; font-weight: bold;">where</span>
<span style="color: #008080;">1</span> row <span style="color: #990099; font-weight: bold;">in</span> <span style="color: #990099; font-weight: bold;">set</span> <span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">0.00</span> sec<span style="color: #FF00FF;">&#41;</span></pre></div></div><p>In the query with the NULL, it does a full table scan. So, if you&#8217;ve run into this problem under MySQL 5.1, the workaround is to remove the NULL. This doesn&#8217;t affect MySQL 4.x or 5.0.</p><p>You can also follow along with <a
href="http://bugs.mysql.com/44139">Bug #33139</a>.</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2009/04/08/dont-put-a-null-in-the-in-clause-in-51/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Replication with InnoDB and MyISAM Transactions</title><link>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/</link> <comments>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/#comments</comments> <pubDate>Fri, 13 Feb 2009 05:26:57 +0000</pubDate> <dc:creator>Gary</dc:creator> <category><![CDATA[MySQL]]></category> <category><![CDATA[MySQL 5.1]]></category> <category><![CDATA[RBR]]></category> <category><![CDATA[regression]]></category> <category><![CDATA[replication]]></category> <guid
isPermaLink="false">http://pento.net/blog/?p=3</guid> <description><![CDATA[There&#8217;s a change of behaviour in MySQL 5.1.31 for Row Based Replication, if you have InnoDB transactions that also write to a MyISAM (or other non-transactional engine) table. It&#8217;s a side effect of fixing Bug #40116. Take this simple example: TRANSACTION 1: INSERT INTO myisam_tbl &#40;item, val&#41; VALUES &#40;1, 0&#41;; TRANSACTION 1: INSERT INTO innodb_tbl [...]]]></description> <content:encoded><![CDATA[<p>There&#8217;s a change of behaviour in MySQL 5.1.31 for Row Based Replication, if you have InnoDB transactions that also write to a MyISAM (or other non-transactional engine) table. It&#8217;s a side effect of fixing <a
title="MySQL Bug #40116: Uncommited changes are replicated and stay on slave after rollback on master" href="http://bugs.mysql.com/40116">Bug #40116</a>. Take this simple example:</p><div
class="wp_syntax"><div
class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> myisam_tbl <span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">,</span> val<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> innodb_tbl <span style="color: #66cc66;">&#40;</span>item<span style="color: #66cc66;">,</span> val<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #66cc66;">-</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">TRANSACTION</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> myisam_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span>val<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> innodb_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> val <span style="color: #993333; font-weight: bold;">FROM</span> myisam_tbl <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">START</span> <span style="color: #993333; font-weight: bold;">TRANSACTION</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> myisam_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span>val<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: <span style="color: #993333; font-weight: bold;">UPDATE</span> innodb_tbl <span style="color: #993333; font-weight: bold;">SET</span> val<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> val <span style="color: #993333; font-weight: bold;">FROM</span> myisam_tbl <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> item<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">2</span>;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">2</span>: COMMIT;
<span style="color: #993333; font-weight: bold;">TRANSACTION</span> <span style="color: #cc66cc;">1</span>: COMMIT;</pre></div></div><p>After this, the Master innodb_tbl would look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>1</td></tr><tr><td>2</td><td>2</td></tr></tbody></table><p>And the Master myisam_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>2</td></tr></tbody></table><p>In 5.1.30 and earlier, the Slave tables will be correct. However, in 5.1.31, the Slave myisam_tbl will be correct, but the innodb_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>0</td></tr><tr><td>2</td><td>1</td></tr></tbody></table><p>As a bonus, there&#8217;s no workaround. Statement Based Replication has never worked for this case. For an SBR Slave (In MySQL 5.0.x and 5.1.x), the Slave myisam_tbl will be correct, but the Slave innodb_tbl will look like this:</p><table><tbody><tr><th>item</th><th>val</th></tr><tr><td>1</td><td>2</td></tr><tr><td>2</td><td>2</td></tr></tbody></table><p>And so, we come to the moral of the story. Don&#8217;t use non-transactional tables in the middle of a transaction. Ever. You will only cause yourself more pain than you can possibly imagine. Instead, move the writes to the non-transactional tables outside of the transaction.</p> ]]></content:encoded> <wfw:commentRss>http://pento.net/2009/02/13/replication-with-innodb-and-myisam-transactions/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
