<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Using flow control functions for performance monitoring queries</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: krteQ</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-311989</link>
		<dc:creator>krteQ</dc:creator>
		<pubDate>Tue, 10 Jun 2008 14:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-311989</guid>
		<description>Peter,

for more interesting results, I usually use something like:

SELECT wtimeRounded
     , ROUND(pcnt,1) AS totalPcnt
     , ROUND(@a := @a + pcnt, 3) AS pcntSum
     , cnt
 FROM (
     SELECT COUNT(*) AS cnt
          , CEIL(wtime * 100)/100 AS wtimeRounded
          , (COUNT(*) / (SELECT COUNT(*) FROM performance_log_080523) * 100) AS pcnt
      FROM performance_log_080523 
     GROUP BY CEIL(wtime * 100)/100 # HAVING COUNT(*) &gt; 5
     ORDER BY wtime2 ASC
 ) AS tmp1;

which shows percentages divided by specified time interval - useful for generating performance graphs.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>for more interesting results, I usually use something like:</p>
<p>SELECT wtimeRounded<br />
     , ROUND(pcnt,1) AS totalPcnt<br />
     , ROUND(@a := @a + pcnt, 3) AS pcntSum<br />
     , cnt<br />
 FROM (<br />
     SELECT COUNT(*) AS cnt<br />
          , CEIL(wtime * 100)/100 AS wtimeRounded<br />
          , (COUNT(*) / (SELECT COUNT(*) FROM performance_log_080523) * 100) AS pcnt<br />
      FROM performance_log_080523<br />
     GROUP BY CEIL(wtime * 100)/100 # HAVING COUNT(*) &gt; 5<br />
     ORDER BY wtime2 ASC<br />
 ) AS tmp1;</p>
<p>which shows percentages divided by specified time interval &#8211; useful for generating performance graphs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: krteQ</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-311980</link>
		<dc:creator>krteQ</dc:creator>
		<pubDate>Tue, 10 Jun 2008 14:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-311980</guid>
		<description>Jakub,

you&#039;re right, but just in this particular case. What about:

mysql&gt; SELECT IF(1 = NULL, 1, 0), (1 = NULL);
+--------------------+------------+
&#124; IF(1 = NULL, 1, 0) &#124; (1 = NULL) &#124;
+--------------------+------------+
&#124;                  0 &#124;       NULL &#124;
+--------------------+------------+
1 row in set (0.00 sec)</description>
		<content:encoded><![CDATA[<p>Jakub,</p>
<p>you&#8217;re right, but just in this particular case. What about:</p>
<p>mysql&gt; SELECT IF(1 = NULL, 1, 0), (1 = NULL);<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+<br />
| IF(1 = NULL, 1, 0) | (1 = NULL) |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+<br />
|                  0 |       NULL |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+<br />
1 row in set (0.00 sec)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MySQL Fan</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-306251</link>
		<dc:creator>MySQL Fan</dc:creator>
		<pubDate>Wed, 28 May 2008 22:42:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-306251</guid>
		<description>Peter,

I strongly believe that your efforts and contributions are more than well received by MySQL&#039;s team. Yet, I still don&#039;t see results. And now you&#039;re saying that will take a couple of years to re-write the optimizer, on top of the ten years or more that have been spent to bring mysql up to this level. Hmm, isn&#039;t that kind of a long time dedicated to build a, hmm, let&#039;s say strong product?! I know that Rome wasn&#039;t built in a day but still...

Ah, and add to that list the sql layer (a bunch of if/case statements) and the lack of a consistent behaviour across the storage engines, just to start with. Add to my argument the same amount of time I mentioned earlier.

Now that MySQL is part of Sun, they don&#039;t have any excuse: it&#039;s time for MySQL to REALLY shine with a REALLY strong product. Advocate for this and blog about it because you have the means. The users are waiting for maturity as change.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I strongly believe that your efforts and contributions are more than well received by MySQL&#8217;s team. Yet, I still don&#8217;t see results. And now you&#8217;re saying that will take a couple of years to re-write the optimizer, on top of the ten years or more that have been spent to bring mysql up to this level. Hmm, isn&#8217;t that kind of a long time dedicated to build a, hmm, let&#8217;s say strong product?! I know that Rome wasn&#8217;t built in a day but still&#8230;</p>
<p>Ah, and add to that list the sql layer (a bunch of if/case statements) and the lack of a consistent behaviour across the storage engines, just to start with. Add to my argument the same amount of time I mentioned earlier.</p>
<p>Now that MySQL is part of Sun, they don&#8217;t have any excuse: it&#8217;s time for MySQL to REALLY shine with a REALLY strong product. Advocate for this and blog about it because you have the means. The users are waiting for maturity as change.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-306244</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Wed, 28 May 2008 22:09:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-306244</guid>
		<description>This is example of practical thinking.  I know MySQL optimizer will not be fixed to handle these during the next couple of years while I deal with systems which must work now. 

I am constantly providing feedback to the optimizer team of what else could be fixed and believe me they know about a lot of stuff which needs to be done themselves but it takes a lot of time to get done.

Not to mention there are cases which simply can;t be optimized as well as equivalent set of queries without flow control functions.</description>
		<content:encoded><![CDATA[<p>This is example of practical thinking.  I know MySQL optimizer will not be fixed to handle these during the next couple of years while I deal with systems which must work now. </p>
<p>I am constantly providing feedback to the optimizer team of what else could be fixed and believe me they know about a lot of stuff which needs to be done themselves but it takes a lot of time to get done.</p>
<p>Not to mention there are cases which simply can;t be optimized as well as equivalent set of queries without flow control functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MySQL Fan</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-306148</link>
		<dc:creator>MySQL Fan</dc:creator>
		<pubDate>Wed, 28 May 2008 16:24:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-306148</guid>
		<description>Peter,

I think this is an example a retrograde thinking:
&quot;I&#039;m not big fan on flow control functions like IF or CASE used in MySQL Queries as they are often abused used to create queries which are poorly readable as well as can hardly be optimized well by MySQL Optimizer.&quot;

Well, in this case, how about convincing MySQL AB/Sun to write a real optimizer and tackle the root of the problem? Write a Query Optimizer in such way that will handle well those if/case control functions. It&#039;s time for MySQL RDBMS to evolve.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>I think this is an example a retrograde thinking:<br />
&#8220;I&#8217;m not big fan on flow control functions like IF or CASE used in MySQL Queries as they are often abused used to create queries which are poorly readable as well as can hardly be optimized well by MySQL Optimizer.&#8221;</p>
<p>Well, in this case, how about convincing MySQL AB/Sun to write a real optimizer and tackle the root of the problem? Write a Query Optimizer in such way that will handle well those if/case control functions. It&#8217;s time for MySQL RDBMS to evolve.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-305541</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Tue, 27 May 2008 03:28:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-305541</guid>
		<description>Jakub,

Indeed. Though I do not like &quot;hackish&quot; approach using things side affect way :)</description>
		<content:encoded><![CDATA[<p>Jakub,</p>
<p>Indeed. Though I do not like &#8220;hackish&#8221; approach using things side affect way <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-305346</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 26 May 2008 17:20:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-305346</guid>
		<description>Parvesh,

Oh yes I know :)

These inclusive times, rather than ranges are OK for me  - in fact it is what I would like to know - what percent goes over 0.3  overall - is what is &quot;bad&quot; and when from there I can visually drill down in how bad is it :)</description>
		<content:encoded><![CDATA[<p>Parvesh,</p>
<p>Oh yes I know <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>These inclusive times, rather than ranges are OK for me  &#8211; in fact it is what I would like to know &#8211; what percent goes over 0.3  overall &#8211; is what is &#8220;bad&#8221; and when from there I can visually drill down in how bad is it <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Parvesh</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-305267</link>
		<dc:creator>Parvesh</dc:creator>
		<pubDate>Mon, 26 May 2008 08:31:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-305267</guid>
		<description>Peter,

On a slightly different note, the SQLs just check on the lower limit i.e., IF(wtime&gt;0.3,1,0), instead it should be IF(wtime BETWEEN 0.3 AND 1, 1, 0). Otherwise, your &quot;so-so&quot; results include poor and fatal also. So, in your first query, the &#039;so-so&#039; should be around 8%.</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>On a slightly different note, the SQLs just check on the lower limit i.e., IF(wtime&gt;0.3,1,0), instead it should be IF(wtime BETWEEN 0.3 AND 1, 1, 0). Otherwise, your &#8220;so-so&#8221; results include poor and fatal also. So, in your first query, the &#8217;so-so&#8217; should be around 8%.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jakub Vrána</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-305266</link>
		<dc:creator>Jakub Vrána</dc:creator>
		<pubDate>Mon, 26 May 2008 08:30:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-305266</guid>
		<description>IF(cond, 1, 0) is the same as (cond) in MySQL so flow control functions are not necessary in this article :-).</description>
		<content:encoded><![CDATA[<p>IF(cond, 1, 0) is the same as (cond) in MySQL so flow control functions are not necessary in this article <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2008/05/24/using-flow-control-functions-for-performance-monitoring/comment-page-1/#comment-304717</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sat, 24 May 2008 16:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/?p=403#comment-304717</guid>
		<description>Lukas,

Then you&#039;re lucky :)  In this case you can see functions are used in SELECT list this is safe,  if they are used in WHERE or  JOIN clause it is a big issue

Something like IF(a.field_1&gt;2,a.field2,5)=b.field1   restricts possible order of joins.

If you can fold multiple queries in one (like in this example) it is surely good idea.</description>
		<content:encoded><![CDATA[<p>Lukas,</p>
<p>Then you&#8217;re lucky <img src='http://www.mysqlperformanceblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   In this case you can see functions are used in SELECT list this is safe,  if they are used in WHERE or  JOIN clause it is a big issue</p>
<p>Something like IF(a.field_1>2,a.field2,5)=b.field1   restricts possible order of joins.</p>
<p>If you can fold multiple queries in one (like in this example) it is surely good idea.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
