<?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 Preacher &#187; variables</title>
	<atom:link href="http://mysqlpreacher.com/wordpress/tag/variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://mysqlpreacher.com/wordpress</link>
	<description>A MySQL blog, from a MySQL DBA</description>
	<lastBuildDate>Wed, 16 Jun 2010 13:13:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL vs InfoBright optimizer battle</title>
		<link>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/</link>
		<comments>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 17:33:36 +0000</pubDate>
		<dc:creator>Darren Cassar</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[infobright]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimiser]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://mysqlpreacher.com/wordpress/?p=302</guid>
		<description><![CDATA[MySQL instance running an Infobright engine

mysql> explain SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a;
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+
&#124; id &#124; select_type &#124; table &#124; type &#124; possible_keys &#124; key  &#124; key_len &#124; ref  &#124; rows    &#124; Extra &#124;
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+
&#124;  1 &#124; SIMPLE      &#124; ac    &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL instance running an Infobright engine</p>
<blockquote><p><code lang="sql"><br />
mysql> explain SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a;<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows    | Extra |<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
|  1 | SIMPLE      | ac    | ALL  | NULL          | NULL | NULL    | NULL |  124426 |       |<br />
|  1 | SIMPLE      | a     | ALL  | NULL          | NULL | NULL    | NULL | 7594256 |       |<br />
+----+-------------+-------+------+---------------+------+---------+------+---------+-------+<br />
2 rows in set (0.01 sec)</p>
<p>mysql> SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a ON ac.UID=a.UID;<br />
+---------------+<br />
| COUNT(ac.UID) |<br />
+---------------+<br />
|         17466 |<br />
+---------------+<br />
1 row in set (0.23 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a ON ac.UID=a.UID); </p>
<p>^CQuery aborted by Ctrl+C<br />
</code></p></blockquote>
<p>Took more than 60seconds &#8212;- what the &#8230;..<br />
Why did it take a long?</p>
<blockquote><p><code lang="sql"><br />
mysql> set @a=2;<br />
Query OK, 0 rows affected (0.00 sec)</p>
<p>mysql> select @a;<br />
+------+<br />
| @a   |<br />
+------+<br />
| 2    |<br />
+------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(*) FROM ACTIVE);<br />
Query OK, 0 rows affected (0.13 sec)</p>
<p>mysql> select @tot;<br />
+--------+<br />
| @tot   |<br />
+--------+<br />
| 124426 |<br />
+--------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> set @tot = (SELECT COUNT(ac.UID) FROM ACTIVE ac);<br />
Query OK, 0 rows affected (0.22 sec)</p>
<p>mysql> select @tot;<br />
+--------+<br />
| @tot   |<br />
+--------+<br />
| 124426 |<br />
+--------+<br />
1 row in set (0.00 sec)</p>
<p>mysql> SELECT COUNT(ac.UID) FROM ACTIVE ac, ALL a;<br />
+---------------+<br />
| COUNT(ac.UID) |<br />
+---------------+<br />
|  944922897056 |<br />
+---------------+<br />
1 row in set (0.05 sec)</p>
<p>mysql> set @tot=(SELECT COUNT(ac.UID) FROM ACTIVE ac JOIN ALL a);<br />
^CQuery aborted by Ctrl+C<br />
ERROR 1317 (70100): Query execution was interrupted<br />
</code></p></blockquote>
<p>Reason? &#8230;. the query is using the MySQL optimiser rather than the IB one! Why? good question (will have to ask IB devs though).</p>
<p>Work around, use ac temporary table to store the result and setting the variable to the result field, but it&#8217;s really ugly isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://mysqlpreacher.com/wordpress/2009/12/mysql-vs-infobright-optimizer-battle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
