<?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/"
	>

<channel>
	<title>Mark Leith</title>
	<atom:link href="http://www.markleith.co.uk/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.markleith.co.uk</link>
	<description>Welcome to my little world</description>
	<pubDate>Thu, 19 Aug 2010 08:50:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Improving InnoDB Transaction Reporting</title>
		<link>http://www.markleith.co.uk/?p=367</link>
		<comments>http://www.markleith.co.uk/?p=367#comments</comments>
		<pubDate>Wed, 18 Aug 2010 18:06:25 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[INFORMATION_SCHEMA]]></category>

		<category><![CDATA[InnoDB]]></category>

		<category><![CDATA[patches]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=367</guid>
		<description><![CDATA[Everybody knows that parsing the output of SHOW ENGINE INNODB STATUS is hard, especially when you want to track the information historically, or want to aggregate any of the more dynamic sections such as the TRANSACTIONS one. 
Within the InnoDB plugin the INFORMATION_SCHEMA.INNODB_TRX table was added, which allowed you to at least get some of [...]]]></description>
			<content:encoded><![CDATA[<p>Everybody knows that <a href="http://www.xaprb.com/blog/2010/04/20/breaking-news-show-innodb-status-ported-to-xml/">parsing the output of SHOW ENGINE INNODB STATUS is hard</a>, especially when you want to track the information historically, or want to aggregate any of the more dynamic sections such as the TRANSACTIONS one. </p>
<p>Within the InnoDB plugin the <a href="http://dev.mysql.com/doc/innodb-plugin/1.0/en/innodb-information-schema-innodb_trx.html">INFORMATION_SCHEMA.INNODB_TRX</a> table was added, which allowed you to at least get some of the information on each transaction, but not the full breadth of information that SHOW ENGINE INNODB STATUS provided. </p>
<p>&#8220;This is nice..&#8221; I thought &#8220;..but why not go the whole hog..?&#8221;.. And so I set about doing that, and opened up <a href="http://bugs.mysql.com/?id=53336">Bug#53336</a>. In a very short time, I was in a review process with the InnoDB team, the patch was cleaned up, and (after a <a href="http://bugs.mysql.com/bug.php?id=55395">little hiccup</a>) everything has been pushed for the next milestone. </p>
<p>Here&#8217;s the docs notes that I wrote for it today (with a little more annotation):</p>
<p>This patch adds the following columns:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">DESC</span> innodb_trx;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------------+---------------------+------+-----+---------------------+-------+</span>
<span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">FIELD</span>                      <span style="color: #66cc66;">|</span> Type                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span>             <span style="color: #66cc66;">|</span> Extra <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------------+---------------------+------+-----+---------------------+-------+</span>
<span style="color: #66cc66;">...</span>
<span style="color: #66cc66;">|</span> trx_operation_state        <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span>         <span style="color: #66cc66;">|</span> YES  <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span>                <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_tables_in_use          <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_tables_locked          <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_lock_structs           <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_lock_memory_bytes      <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_rows_locked            <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_rows_modified          <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_concurrency_tickets    <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_isolation_level        <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span>         <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span>                     <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_unique_checks          <span style="color: #66cc66;">|</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>              <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_foreign_key_checks     <span style="color: #66cc66;">|</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>              <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_last_foreign_key_error <span style="color: #66cc66;">|</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span>        <span style="color: #66cc66;">|</span> YES  <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NULL</span>                <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_adaptive_hash_latched  <span style="color: #66cc66;">|</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>              <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">|</span> trx_adaptive_hash_timeout  <span style="color: #66cc66;">|</span> bigint<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">21</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #66cc66;">|</span> NO   <span style="color: #66cc66;">|</span>     <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>                   <span style="color: #66cc66;">|</span>       <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------------------------+---------------------+------+-----+---------------------+-------+</span>
<span style="color: #cc66cc;">22</span> rows <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.05</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Most of these are self explanatory, a lot of them duplicate the information within SHOW ENGINE INNODB STATUS (so you now no longer need to parse the output of that to get complete transaction information).</p>
<p>Below are some of my notes. For comparison, here&#8217;s an example of a transaction from the SHOW ENGINE INNODB STATUS statement:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">---TRANSACTION 517, ACTIVE 1 sec, OS thread id 2958520320 inserting</span>
mysql <span style="color: #993333; font-weight: bold;">TABLES</span> <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">USE</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> locked <span style="color: #cc66cc;">2</span>
<span style="color: #cc66cc;">189</span> <span style="color: #993333; font-weight: bold;">LOCK</span> struct<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> heap size <span style="color: #cc66cc;">27968</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">54389</span> row <span style="color: #993333; font-weight: bold;">LOCK</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> undo log entries <span style="color: #cc66cc;">2406</span>
MySQL thread id <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> query id <span style="color: #cc66cc;">36</span> localhost root Sending <span style="color: #993333; font-weight: bold;">DATA</span>
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">IGNORE</span> <span style="color: #993333; font-weight: bold;">INTO</span> t1 <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">&#40;</span>i <span style="color: #66cc66;">*</span> rand<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">FROM</span> t1<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p><strong>trx_operation_state</strong>  - corresponds to &#8220;inserting&#8221;, InnoDB&#8217;s internal transaction state<br />
<strong>trx_tables_in_use</strong> - corresponds to &#8220;mysql tables in use 2&#8243;, the number of table locks requested by MySQL via external_lock()<br />
<strong>trx_tables_locked</strong> - corresponds to &#8220;locked 2&#8243;, the number of actual table locks taken via external_lock()<br />
<strong>trx_lock_structs</strong> - corresponds to &#8220;189 lock struct(s)&#8221;, the size of the lock struct list<br />
<strong>trx_lock_memory_bytes</strong> - corresponds to &#8220;heap size 27968&#8243;, the number of bytes allocated to locks structs<br />
<strong>trx_rows_locked</strong> - corresponds to &#8220;54389 row lock(s)&#8221;, an estimation of the number of rows locked (delete marked rows may make it imprecise)<br />
trx_rows_modified - corresponds to &#8220;undo log entries 2406&#8243;, the number of rows modified in the transaction (inserted, updated, deleted)</p>
<p>Not seen in the transaction output above:</p>
<p><strong>trx_concurrency_tickets</strong> - corresponds to &#8220;thread declared inside InnoDB 89&#8243; for a transaction in SHOW ENGINE INNODB STATUS, the number of concurrency tickets remaining for the transaction when innodb_thread_concurrency != 0<br />
<strong>trx_isolation_level</strong> - the transactions isolation level<br />
<strong>trx_unique_checks</strong> - whether the transaction has &#8220;SET UNIQUE_CHECKS = 0&#8243;<br />
<strong>trx_foreign_key_checks</strong> - whether the transaction has &#8220;SET FOREIGN_KEY_CHECKS = 0&#8243;<br />
<strong>trx_last_foreign_key_error</strong> - if the last statement in the transaction resulted in an FK error, the error text is printed here<br />
<strong>trx_adaptive_hash_latched</strong> - corresponds to &#8220;holds adaptive hash latch&#8221; being printed for a transaction in SHOW ENGINE INNODB STATUS<br />
<strong>trx_adaptive_hash_timeout</strong> - when innodb_adapative_hash_index is enabled (default), statements that try to get the adapative hash latch spin 10000 (BTR_SEA_TIMEOUT) times, re-trying getting the adaptive hash latch, before giving up. lower numbers here for a lot of transactions may indicate contention on the adaptive hash latch </p>
<p>In summary - no more having to parse SHOW ENGINE INNODB STATUS output for transaction information, now you can just do it with SQL (with all it&#8217;s aggregation goodness as well if you want to)!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=367</wfw:commentRss>
		</item>
		<item>
		<title>Starting a new job!</title>
		<link>http://www.markleith.co.uk/?p=347</link>
		<comments>http://www.markleith.co.uk/?p=347#comments</comments>
		<pubDate>Wed, 05 May 2010 21:01:43 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[MEM]]></category>

		<category><![CDATA[Support Team]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=347</guid>
		<description><![CDATA[I&#8217;ve had a wild ride over the past ~4.5 years, starting with MySQL AB as a &#8220;Support Engineer&#8221;, and working through to &#8220;Senior Support Engineer&#8221;, and then &#8220;Regional Support Manager, Americas&#8221; with the MySQL Support Team - truly one of the best product support teams I&#8217;ve ever known in the IT industry, even if I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a wild ride over the past ~4.5 years, starting with MySQL AB as a &#8220;Support Engineer&#8221;, and working through to &#8220;Senior Support Engineer&#8221;, and then &#8220;Regional Support Manager, Americas&#8221; with the MySQL Support Team - truly one of the best product support teams I&#8217;ve ever known in the IT industry, even if I am biased. </p>
<p>I&#8217;ve always had a passion for helping people, which is why I think I did &#8220;OK&#8221; in Support. However I&#8217;ve always also had a second passion which has been bubbling away for me too - building solutions for diagnosing database issues. I started in the database world in the Oracle market, working on monitoring and management tools. MySQL &#8220;poached&#8221; me from there whilst I was building a MySQL monitoring module for the cross database monitoring tool that we had, as well as working in a supporting/consulting role for our customers. </p>
<p>Given my background when I joined, I was an obvious person to be put in to an internal coordinator role to manage interaction between the team that develops <a href="http://www.mysql.com/products/enterprise/monitor.html">MySQL Enterprise Monitor</a> and Support back then (before MEM reached it&#8217;s first GA), so I also had the pleasure of working with that team pretty closely for my time in Support. </p>
<p>It satisfied my second passion for a long time. Now it&#8217;s time to take the leap back to that full time!</p>
<p>At the start of this week I started in my new role, as a &#8220;Software Development Manager&#8221; for the Enterprise Tools team, still within MySQL/Oracle, working full time on MySQL Enterprise Monitor and MySQL Proxy.</p>
<p>I&#8217;m pretty excited about the new role - I want to help make monitoring and management of MySQL easy, both by getting more of the &#8220;right&#8221; data from the server, and by representing it all in coherent ways for DBAs in our tools, so that they too can be more productive in making the right choices when managing their systems. I feel pretty well placed to do that now. <img src='http://www.markleith.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If you&#8217;re a customer that has used MEM and wants to give any feedback, or even just an interested user in the community - I&#8217;m all ears, either leave your comments here, or ping me by email (first_name.last_name@oracle.com) - I&#8217;d love to have some discussions with you about your needs, likes, or dislikes.</p>
<p>I thank every person in Support for my time with them, however I owe all of that time to one fairly anonymous guy in the &#8220;external&#8221; MySQL world, but a man mountain &#8220;internally&#8221; - <a href="http://dev.mysql.com/tech-resources/interviews/dellis.html">Dean Ellis</a>, the man who convinced me to join MySQL AB all those years ago, and has been a fantastic mentor and manager over the years to me.  Mr Ellis - I salute you. Thanks for bringing me on the ride, I still don&#8217;t regret it, no matter how much you tried to make me! <img src='http://www.markleith.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Enterprise Tools team - Look Out, you have me to whine at you full time now!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=347</wfw:commentRss>
		</item>
		<item>
		<title>A morning hack - Com_change_user</title>
		<link>http://www.markleith.co.uk/?p=337</link>
		<comments>http://www.markleith.co.uk/?p=337#comments</comments>
		<pubDate>Wed, 03 Mar 2010 11:06:56 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[patches]]></category>

		<category><![CDATA[SHOW statements]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=337</guid>
		<description><![CDATA[So after I published my patch last night, another of my colleagues - the esteemed Shane Bester - pointed out that there is a related bug - Bug#28405 - which requests that Com_change_user is also split out from Com_admin_commands. 
So I extended my patch this morning, to kill two birds with one stone:

=== modified file [...]]]></description>
			<content:encoded><![CDATA[<p>So after I published my patch last night, another of my colleagues - the esteemed Shane Bester - pointed out that there is a related bug - <a href="http://bugs.mysql.com/bug.php?id=28405">Bug#28405</a> - which requests that Com_change_user is also split out from Com_admin_commands. </p>
<p>So I extended my patch this morning, to kill two birds with one stone:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">===</span> modified file <span style="color: #ff0000;">'sql/mysqld.cc'</span>
<span style="color: #339933;">---</span> sql<span style="color: #339933;">/</span>mysqld.<span style="color: #202020;">cc</span>       revid<span style="color: #339933;">:</span>alik@sun.<span style="color: #202020;">com</span><span style="color: #339933;">-</span><span style="color: #0000dd;">20100114090008</span><span style="color: #339933;">-</span>3rsdmlp1w2mqgrhg
<span style="color: #339933;">+++</span> sql<span style="color: #339933;">/</span>mysqld.<span style="color: #202020;">cc</span>       <span style="color: #0000dd;">2010</span><span style="color: #339933;">-</span><span style="color: #208080;">03</span><span style="color: #339933;">-</span><span style="color: #208080;">03</span> <span style="color:#800080;">09</span><span style="color: #339933;">:</span><span style="color: #0000dd;">57</span><span style="color: #339933;">:</span><span style="color: #0000dd;">40</span> <span style="color: #339933;">+</span><span style="color: #208080;">0000</span>
@@ <span style="color: #339933;">-</span><span style="color: #0000dd;">3131</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span> <span style="color: #339933;">+</span><span style="color: #0000dd;">3131</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span> @@
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;call_procedure&quot;</span><span style="color: #339933;">,</span>       <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_CALL<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;change_db&quot;</span><span style="color: #339933;">,</span>            <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_CHANGE_DB<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;change_master&quot;</span><span style="color: #339933;">,</span>        <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_CHANGE_MASTER<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #339933;">+</span>  <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;change_user&quot;</span><span style="color: #339933;">,</span>          <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_change_user<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;check&quot;</span><span style="color: #339933;">,</span>                <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_CHECK<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;checksum&quot;</span><span style="color: #339933;">,</span>             <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_CHECKSUM<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;commit&quot;</span><span style="color: #339933;">,</span>               <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_COMMIT<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
@@ <span style="color: #339933;">-</span><span style="color: #0000dd;">3174</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span> <span style="color: #339933;">+</span><span style="color: #0000dd;">3175</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span> @@
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;load&quot;</span><span style="color: #339933;">,</span>                 <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_LOAD<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;lock_tables&quot;</span><span style="color: #339933;">,</span>          <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_LOCK_TABLES<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;optimize&quot;</span><span style="color: #339933;">,</span>             <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_OPTIMIZE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #339933;">+</span>  <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;ping&quot;</span><span style="color: #339933;">,</span>                 <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_ping<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;preload_keys&quot;</span><span style="color: #339933;">,</span>         <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PRELOAD_KEYS<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;prepare_sql&quot;</span><span style="color: #339933;">,</span>          <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PREPARE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;purge&quot;</span><span style="color: #339933;">,</span>                <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PURGE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
@@ <span style="color: #339933;">-</span><span style="color: #0000dd;">3350</span><span style="color: #339933;">,</span><span style="color: #0000dd;">11</span> <span style="color: #339933;">+</span><span style="color: #0000dd;">3352</span><span style="color: #339933;">,</span><span style="color: #0000dd;">13</span> @@
     We have few debug<span style="color: #339933;">-</span>only commands in com_status_vars<span style="color: #339933;">,</span> only visible in debug
     builds. <span style="color: #b1b100;">for</span> simplicity we enable the assert only in debug builds
&nbsp;
<span style="color: #339933;">-</span>    There are <span style="color: #0000dd;">8</span> Com_ variables which don<span style="color: #ff0000;">'t have corresponding SQLCOM_ values:
+    There are 10 Com_ variables which don'</span>t have corresponding SQLCOM_ values<span style="color: #339933;">:</span>
     <span style="color: #009900;">&#40;</span>TODO strictly speaking they shouldn<span style="color: #ff0000;">'t be here, should not have Com_ prefix
     that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?)
&nbsp;
       Com_admin_commands       =&gt; com_other
+      Com_change_user          =&gt; com_change_user
+      Com_ping                 =&gt; com_ping
       Com_stmt_close           =&gt; com_stmt_close
       Com_stmt_execute         =&gt; com_stmt_execute
       Com_stmt_fetch           =&gt; com_stmt_fetch
@@ -3368,7 +3372,7 @@
     of SQLCOM_ constants.
   */
   compile_time_assert(sizeof(com_status_vars)/sizeof(com_status_vars[0]) - 1 ==
-                     SQLCOM_END + 8);
+                     SQLCOM_END + 10);
 #endif
&nbsp;
   if (get_options(&amp;remaining_argc, &amp;remaining_argv))
&nbsp;
=== modified file '</span>sql<span style="color: #339933;">/</span>sql_class.<span style="color: #202020;">h</span><span style="color: #ff0000;">'
--- sql/sql_class.h     revid:alik@sun.com-20100114090008-3rsdmlp1w2mqgrhg
+++ sql/sql_class.h     2010-03-03 09:56:18 +0000
@@ -443,6 +443,8 @@
   ulong ha_discover_count;
   ulong ha_savepoint_count;
   ulong ha_savepoint_rollback_count;
+  ulong com_ping;
+  ulong com_change_user;
&nbsp;
   /* KEY_CACHE parts. These are copies of the original */
   ulong key_blocks_changed;
&nbsp;
=== modified file '</span>sql<span style="color: #339933;">/</span>sql_parse.<span style="color: #202020;">cc</span><span style="color: #ff0000;">'
--- sql/sql_parse.cc    revid:alik@sun.com-20100114090008-3rsdmlp1w2mqgrhg
+++ sql/sql_parse.cc    2010-03-03 09:56:19 +0000
@@ -979,7 +979,7 @@
 #endif
   case COM_CHANGE_USER:
   {
-    status_var_increment(thd-&gt;status_var.com_other);
+    status_var_increment(thd-&gt;status_var.com_change_user);
     char *user= (char*) packet, *packet_end= packet + packet_length;
     /* Safe because there is always a trailing <span style="color: #006699; font-weight: bold;">\0</span> at the end of the packet */
     char *passwd= strend(user)+1;
@@ -1409,7 +1409,7 @@
     break;
   }
   case COM_PING:
-    status_var_increment(thd-&gt;status_var.com_other);
+    status_var_increment(thd-&gt;status_var.com_ping);
     my_ok(thd);                                // Tell client we are alive
     break;
   case COM_PROCESS_INFO:</span></pre></div></div>

<p>Again, a quick test script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> mysqli_connect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'msandbox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5550</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>mysqli_change_user<span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'msandbox'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Change user failed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;User changed!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And test:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P5550 <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_change_user'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name   <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_change_user <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
Cerberus:msb_5_5_5 mark$ php ~<span style="color: #66cc66;">/</span>Dev<span style="color: #66cc66;">/</span>tests<span style="color: #66cc66;">/</span>com_change_user<span style="color: #66cc66;">.</span>php
User changed!
Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P5550 <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_change_user'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name   <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_change_user <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
Cerberus:msb_5_5_5 mark$ php ~<span style="color: #66cc66;">/</span>Dev<span style="color: #66cc66;">/</span>tests<span style="color: #66cc66;">/</span>com_change_user<span style="color: #66cc66;">.</span>php
User changed!
Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P5550 <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_change_user'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name   <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_change_user <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">2</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------+-------+</span></pre></div></div>

<p><strong>Yet Another Disclaimer: Not sure if/when/where this might get in! It is a change in behavior with regards to Com_admin_commands</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=337</wfw:commentRss>
		</item>
		<item>
		<title>An evening hack - Com_ping</title>
		<link>http://www.markleith.co.uk/?p=327</link>
		<comments>http://www.markleith.co.uk/?p=327#comments</comments>
		<pubDate>Wed, 03 Mar 2010 00:06:16 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=327</guid>
		<description><![CDATA[My boss vented about the lack of a Com_ping SHOW GLOBAL STATUS variable earlier, and I figured it would be dead easy to hack in. 
A few minutes later:

Cerberus:mysql-next-mr mark$ bzr diff ./sql
=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc       revid:alik@sun.com-20100114090008-3rsdmlp1w2mqgrhg
+++ sql/mysqld.cc       2010-03-02 22:58:45 +0000
@@ -3174,6 [...]]]></description>
			<content:encoded><![CDATA[<p>My boss vented about the lack of a Com_ping SHOW GLOBAL STATUS variable earlier, and I figured it would be dead easy to hack in. </p>
<p>A few minutes later:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">Cerberus<span style="color: #339933;">:</span>mysql<span style="color: #339933;">-</span>next<span style="color: #339933;">-</span>mr mark$ bzr diff .<span style="color: #339933;">/</span>sql
<span style="color: #339933;">===</span> modified file <span style="color: #ff0000;">'sql/mysqld.cc'</span>
<span style="color: #339933;">---</span> sql<span style="color: #339933;">/</span>mysqld.<span style="color: #202020;">cc</span>       revid<span style="color: #339933;">:</span>alik@sun.<span style="color: #202020;">com</span><span style="color: #339933;">-</span><span style="color: #0000dd;">20100114090008</span><span style="color: #339933;">-</span>3rsdmlp1w2mqgrhg
<span style="color: #339933;">+++</span> sql<span style="color: #339933;">/</span>mysqld.<span style="color: #202020;">cc</span>       <span style="color: #0000dd;">2010</span><span style="color: #339933;">-</span><span style="color: #208080;">03</span><span style="color: #339933;">-</span><span style="color: #208080;">02</span> <span style="color: #0000dd;">22</span><span style="color: #339933;">:</span><span style="color: #0000dd;">58</span><span style="color: #339933;">:</span><span style="color: #0000dd;">45</span> <span style="color: #339933;">+</span><span style="color: #208080;">0000</span>
@@ <span style="color: #339933;">-</span><span style="color: #0000dd;">3174</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span> <span style="color: #339933;">+</span><span style="color: #0000dd;">3174</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span> @@
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;load&quot;</span><span style="color: #339933;">,</span>                 <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_LOAD<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;lock_tables&quot;</span><span style="color: #339933;">,</span>          <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_LOCK_TABLES<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;optimize&quot;</span><span style="color: #339933;">,</span>             <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_OPTIMIZE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #339933;">+</span>  <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;ping&quot;</span><span style="color: #339933;">,</span>                 <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_ping<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;preload_keys&quot;</span><span style="color: #339933;">,</span>         <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PRELOAD_KEYS<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;prepare_sql&quot;</span><span style="color: #339933;">,</span>          <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PREPARE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   <span style="color: #009900;">&#123;</span><span style="color: #ff0000;">&quot;purge&quot;</span><span style="color: #339933;">,</span>                <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> offsetof<span style="color: #009900;">&#40;</span>STATUS_VAR<span style="color: #339933;">,</span> com_stat<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>uint<span style="color: #009900;">&#41;</span> SQLCOM_PURGE<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> SHOW_LONG_STATUS<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
@@ <span style="color: #339933;">-</span><span style="color: #0000dd;">3350</span><span style="color: #339933;">,</span><span style="color: #0000dd;">11</span> <span style="color: #339933;">+</span><span style="color: #0000dd;">3351</span><span style="color: #339933;">,</span><span style="color: #0000dd;">12</span> @@
     We have few debug<span style="color: #339933;">-</span>only commands in com_status_vars<span style="color: #339933;">,</span> only visible in debug
     builds. <span style="color: #b1b100;">for</span> simplicity we enable the assert only in debug builds
&nbsp;
<span style="color: #339933;">-</span>    There are <span style="color: #0000dd;">8</span> Com_ variables which don<span style="color: #ff0000;">'t have corresponding SQLCOM_ values:
+    There are 9 Com_ variables which don'</span>t have corresponding SQLCOM_ values<span style="color: #339933;">:</span>
     <span style="color: #009900;">&#40;</span>TODO strictly speaking they shouldn<span style="color: #ff0000;">'t be here, should not have Com_ prefix
     that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?)
&nbsp;
       Com_admin_commands       =&gt; com_other
+      Com_ping                 =&gt; com_ping
       Com_stmt_close           =&gt; com_stmt_close
       Com_stmt_execute         =&gt; com_stmt_execute
       Com_stmt_fetch           =&gt; com_stmt_fetch
@@ -3368,7 +3370,7 @@
     of SQLCOM_ constants.
   */
   compile_time_assert(sizeof(com_status_vars)/sizeof(com_status_vars[0]) - 1 ==
-                     SQLCOM_END + 8);
+                     SQLCOM_END + 9);
 #endif
&nbsp;
   if (get_options(&amp;remaining_argc, &amp;remaining_argv))
&nbsp;
=== modified file '</span>sql<span style="color: #339933;">/</span>sql_class.<span style="color: #202020;">h</span><span style="color: #ff0000;">'
--- sql/sql_class.h     revid:alik@sun.com-20100114090008-3rsdmlp1w2mqgrhg
+++ sql/sql_class.h     2010-03-02 22:56:05 +0000
@@ -443,6 +443,7 @@
   ulong ha_discover_count;
   ulong ha_savepoint_count;
   ulong ha_savepoint_rollback_count;
+  ulong com_ping;
&nbsp;
   /* KEY_CACHE parts. These are copies of the original */
   ulong key_blocks_changed;
&nbsp;
=== modified file '</span>sql<span style="color: #339933;">/</span>sql_parse.<span style="color: #202020;">cc</span><span style="color: #ff0000;">'
--- sql/sql_parse.cc    revid:alik@sun.com-20100114090008-3rsdmlp1w2mqgrhg
+++ sql/sql_parse.cc    2010-03-02 23:23:41 +0000
@@ -1409,7 +1409,7 @@
     break;
   }
   case COM_PING:
-    status_var_increment(thd-&gt;status_var.com_other);
+    status_var_increment(thd-&gt;status_var.com_ping);
     my_ok(thd);                                // Tell client we are alive
     break;
   case COM_PROCESS_INFO:</span></pre></div></div>

<p>COM_PING has always historically been recorded under Com_admin_commands (which is tracked with com_other), however this also includes a number of other commands:</p>
<p>COM_TABLE_DUMP<br />
COM_CHANGE_USER<br />
COM_BINLOG_DUMP<br />
COM_SHUTDOWN<br />
COM_DEBUG</p>
<p>COM_CHANGE_USER can also be used frequently with connection pools, as can COM_PING. It would be nice to differentiate them when tracking down issues within such environments. </p>
<p>Here&#8217;s the bug that was opened:</p>
<p><a href="http://bugs.mysql.com/bug.php?id=51667">http://bugs.mysql.com/bug.php?id=51667</a></p>
<p>And a quick test:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P <span style="color: #cc66cc;">5550</span> <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_ping'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_ping      <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">0</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
Cerberus:msb_5_5_5 mark$ php ~<span style="color: #66cc66;">/</span>Dev<span style="color: #66cc66;">/</span>tests<span style="color: #66cc66;">/</span>com_ping<span style="color: #66cc66;">.</span>php
Connected!
Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P <span style="color: #cc66cc;">5550</span> <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_ping'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_ping      <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
Cerberus:msb_5_5_5 mark$ php ~<span style="color: #66cc66;">/</span>Dev<span style="color: #66cc66;">/</span>tests<span style="color: #66cc66;">/</span>com_ping<span style="color: #66cc66;">.</span>php
Connected!
Cerberus:msb_5_5_5 mark$ mysql <span style="color: #66cc66;">-</span>u root <span style="color: #66cc66;">-</span>pmsandbox <span style="color: #66cc66;">-</span>h 127<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>0<span style="color: #66cc66;">.</span>1 <span style="color: #66cc66;">-</span>P <span style="color: #cc66cc;">5550</span> <span style="color: #66cc66;">-</span>e <span style="color: #ff0000;">&quot;show global status like 'com_ping'&quot;</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Variable_name <span style="color: #66cc66;">|</span> Value <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span>
<span style="color: #66cc66;">|</span> Com_ping      <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">2</span>     <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">---------------+-------+</span></pre></div></div>

<p>The test script:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'127.0.0.1:5550'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'msandbox'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">mysql_ping</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Connection Dead!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;Connected!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Disclaimer: Not sure if/when/where this might get in! It is a change in behavior with regards to Com_admin_commands</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=327</wfw:commentRss>
		</item>
		<item>
		<title>PERFORMANCE_SCHEMA hits Prime Time!</title>
		<link>http://www.markleith.co.uk/?p=318</link>
		<comments>http://www.markleith.co.uk/?p=318#comments</comments>
		<pubDate>Thu, 14 Jan 2010 20:21:43 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[performance_schema]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=318</guid>
		<description><![CDATA[I&#8217;ve talked about PERFORMANCE_SCHEMA in the past - almost a year ago now. 
Back then the feature was just coming together in to something useable, and was on the cusp of moving towards code review. It entered code review, and went around, and around for 9 months, whilst various refinements were made. 
Never the less, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve <a href="http://www.markleith.co.uk/?p=112">talked about</a> PERFORMANCE_SCHEMA in the past - almost a year ago now. </p>
<p>Back then the feature was just coming together in to something useable, and was on the cusp of moving towards code review. It entered code review, and went around, and around for <strong>9 months</strong>, whilst various refinements were made. </p>
<p>Never the less, Marc Alff persevered (much respect!), and yesterday pushed his final merge in to the mysql-next-mr bzr tree. PERFORMANCE_SCHEMA is now awaiting the next milestone release, and <strong>will be a part of the next GA release of MySQL!</strong></p>
<p>We have the initial documentation ready:</p>
<p><a href="http://dev.mysql.com/doc/performance-schema/en/index.html">http://dev.mysql.com/doc/performance-schema/en/index.html</a></p>
<p>This first round adds the infrastructure to take monitoring of the MySQL Server to the next level, initially adding in instrumentation for sync points (mutexes, rw locks, etc.) and file IO, in the SQL layer, and most of the default storage engines (all those controlled by MySQL/Sun). </p>
<p>Here&#8217;s a shout out to the other storage engine developers - we&#8217;d love you to start looking at instrumenting your own engines as well. Ask away on the internals@ list - I&#8217;m sure Marc will be more than willing to help. </p>
<p>And now that we have the above in - what&#8217;s next? It&#8217;s a good question! Here&#8217;s a list of the major outstanding worklogs:</p>
<p><a href="http://forge.mysql.com/worklog/task.php?id=4674">WL#4674</a> PERFORMANCE_SCHEMA Setup For Actors<br />
<a href="http://forge.mysql.com/worklog/task.php?id=4895">WL#4895</a> PERFORMANCE_SCHEMA Instrumenting Table IO<br />
<a href="http://forge.mysql.com/worklog/task.php?id=4896">WL#4896</a> PERFORMANCE_SCHEMA Instrumenting Net IO<br />
<a href="http://forge.mysql.com/worklog/task.php?id=4878">WL#4878</a> PERFORMANCE_SCHEMA Trace</p>
<p>Personally, I&#8217;m voting for WL#4895 next (well, I&#8217;d like to see InnoDB instrumentation too!), but you can vote for what ever you are most interested in via the votes in Worklog as well. </p>
<p>Thanks for all the hard work Marc!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=318</wfw:commentRss>
		</item>
		<item>
		<title>Scientists say dolphins should be treated as &#8216;non-human persons&#8217;</title>
		<link>http://www.markleith.co.uk/?p=309</link>
		<comments>http://www.markleith.co.uk/?p=309#comments</comments>
		<pubDate>Mon, 04 Jan 2010 21:32:30 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[dolphins]]></category>

		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=309</guid>
		<description><![CDATA[Being an employee of MySQL (past and present), every time I see something related to dolphins it catches my eye - and I just came across this:
Scientists say dolphins should be treated as &#8216;non-human persons&#8217;
The treatment of dolphins has long been an issue for me, I utterly despise some of the things I have seen, [...]]]></description>
			<content:encoded><![CDATA[<p>Being an employee of MySQL (past and present), every time I see something related to dolphins it catches my eye - and I just came across this:</p>
<p><a href="http://www.timesonline.co.uk/tol/news/science/article6973994.ece#cid=OTC-RSS&#038;attr=797084">Scientists say dolphins should be treated as &#8216;non-human persons&#8217;</a></p>
<p>The treatment of dolphins has long been an issue for me, I utterly despise some of the things I have seen, and read about. MySQL&#8217;s dolphin - Sakila - has always been seen as a symbol of freedom. This is marred by reality, hopefully this will change:</p>
<p><em>&#8220;The researchers argue that their work shows it is morally unacceptable to keep such intelligent animals in amusement parks or to kill them for food or by accident when fishing. Some 300,000 whales, dolphins and porpoises die in this way each year.&#8221;</em></p>
<p>Some other things in the article also ring true for me, in other ways. <img src='http://www.markleith.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>&#8220;The studies show how dolphins have distinct personalities, a strong sense of self and can think about the future.&#8221;</p>
<p>&#8220;It has also become clear that they are “cultural” animals, meaning that new types of behaviour can quickly be picked up by one dolphin from another.&#8221;</p>
<p>&#8220;Other research has shown dolphins can solve difficult problems, while those living in the wild co-operate in ways that imply complex social structures and a high level of emotional sophistication.&#8221;</em></p>
<p>FWIW, I&#8217;ve donated to both <a href="http://www.orcaweb.org.uk/">http://www.orcaweb.org.uk/</a> and <a href="http://www.wdcs.org/">http://www.wdcs.org/</a> in the past, they are both wonderfully worthy causes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=309</wfw:commentRss>
		</item>
		<item>
		<title>Grouping by Arbitrary Time Ranges (Graphing What You Can See)</title>
		<link>http://www.markleith.co.uk/?p=290</link>
		<comments>http://www.markleith.co.uk/?p=290#comments</comments>
		<pubDate>Fri, 30 Oct 2009 17:17:56 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[graphs]]></category>

		<category><![CDATA[MEM]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=290</guid>
		<description><![CDATA[First, the back story. One of the MEM developers asked me today about an interesting problem:
We have graphs in MEM that can be generated against an arbitrary time range in the UI - even for a year or more if the data is not purged. Currently MEM does not do any kind of rolling up [...]]]></description>
			<content:encoded><![CDATA[<p>First, the back story. One of the <a href="http://www.mysql.com/products/enterprise/monitor.html" target="_blank">MEM</a> developers asked me today about an interesting problem:</p>
<p>We have graphs in MEM that can be generated against an arbitrary time range in the UI - even for a year or more if the data is not purged. Currently MEM does not do any kind of rolling up of the data (in an RRD style), and pulls graph data from each agent/instance on a 1 minute interval. So if you wanted to pull, for instance, the last 3 months worth of data in to a graph - the server back end basically goes back to the database and requests all of the rows - <strong>all ~43,829 of them, </strong>oh, and that&#8217;s <strong>for each series</strong> - and then calculate deltas on the server side if need be (we store raw values), and stuffs the data in to a graphing library to draw the graph.</p>
<p>Further, graphs are only of a limited (but adjustable) size on the screen - I run MEM with a 900 pixel wide graph personally - so there&#8217;s only ~900 points (maybe a few less, with the axis etc. being shown) that can be filled with data.</p>
<p>Trying to fill 900 points with ~43,000 points is an exercise in futility. Damn those pixels. Why doesn&#8217;t everybody have a cinema in their ops centers? Filling up your memory with all that data on the app server side is also another issue.</p>
<p>So we&#8217;ve been looking at various ways of a) rolling this data in storage, and b) only selecting what can be shown on the screen if possible. The MEM dev hit me up about the latter today, and basically asked - &#8220;Given a time range, and a number of pixels, how we can we group a set of rows together to get an aggregated result that only returns the same number of rows as we have pixels?&#8221;</p>
<p>Math to the rescue!</p>
<p>Luckily we store the timestamps for the data we collect in a BIGINT column - we store a unix style timestamp with millisecond resolution times. If you&#8217;re not doing this, then you should convert your DATETIME / TIMESTAMP etc. to an integer (with UNIX_TIMESTAMP) first.</p>
<p>So I started off with the three known constants:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SET</span> @start_time <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1254325343000</span>; <span style="color: #66cc66;">//</span> About a month ago
<span style="color: #993333; font-weight: bold;">SET</span> @end_time <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">1256908959000</span>; <span style="color: #66cc66;">//</span> About now
<span style="color: #993333; font-weight: bold;">SET</span> @pixels <span style="color: #66cc66;">=</span> <span style="color: #cc66cc;">900</span>;</pre></div></div>

<p>Now, to get the interval that you need to group, you have to first get the full integer range you are dealing with, and then divide it by the number of pixels:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SET</span> @intervals <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>@end_time <span style="color: #66cc66;">-</span> @start_time<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> @pixels<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Now that we know the interval size that we are going to GROUP together, how do we group it? Math to the rescue again - to generate the time slices you round the whole timestamp number to the nearest interval, and then convert it back again, basically:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">FLOOR<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>timestamp_col<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span>  @intervals<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>  @intervals</pre></div></div>

<p>To generate the range, I used a little CONCAT magic (and note that you add one before converting back for the end of the range), and then GROUP BY the output, here&#8217;s an example based on the MEM data set - which stores it&#8217;s timestamp in &#8220;end_time&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> instance_attribute_id<span style="color: #66cc66;">,</span> 
       SUM<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> sum_value<span style="color: #66cc66;">,</span>
       MIN<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> min_value<span style="color: #66cc66;">,</span>
       MAX<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> max_value<span style="color: #66cc66;">,</span>
       AVG<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> avg_value<span style="color: #66cc66;">,</span>
       COUNT<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span> agg_points<span style="color: #66cc66;">,</span>
       CONCAT<span style="color: #66cc66;">&#40;</span> ROUND<span style="color: #66cc66;">&#40;</span> FLOOR<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>end_time<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span>  @intervals<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>  @intervals<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">' - '</span><span style="color: #66cc66;">,</span> 
               ROUND<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>FLOOR<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>end_time<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span>  @intervals <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>  @intervals<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> time_range
  <span style="color: #993333; font-weight: bold;">FROM</span> dc_ng_long_now 
 <span style="color: #993333; font-weight: bold;">WHERE</span> instance_attribute_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">73</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">76</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">77</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">79</span><span style="color: #66cc66;">&#41;</span>  
   <span style="color: #993333; font-weight: bold;">AND</span> end_time <span style="color: #993333; font-weight: bold;">BETWEEN</span> @start_time <span style="color: #993333; font-weight: bold;">AND</span> @end_time
 <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> instance_attribute_id<span style="color: #66cc66;">,</span> time_range</pre></div></div>

<p>The above is what could be used to generate the <em>CPU Usage</em> graph (the instance ID&#8217;s are each of the series) in the MEM UI, for a month of data. Some sample output:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------------+----------------+--------------+--------------+-------------------+------------+-------------------------------+</span>
<span style="color: #66cc66;">|</span> instance_attribute_id <span style="color: #66cc66;">|</span> sum_value      <span style="color: #66cc66;">|</span> min_value    <span style="color: #66cc66;">|</span> max_value    <span style="color: #66cc66;">|</span> avg_value         <span style="color: #66cc66;">|</span> agg_points <span style="color: #66cc66;">|</span> time_range                    <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">-----------------------+----------------+--------------+--------------+-------------------+------------+-------------------------------+</span>
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">884176993340</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442088260860</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442088732480</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442088496670.0000</span> <span style="color: #66cc66;">|</span>          <span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254322602524</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254325473209</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21220811440010</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442089201580</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442111284920</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442100238333.5417</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254325473209</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254328343893</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21221895300670</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442111747690</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442133893930</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442122818763.9583</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254328343893</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254331214578</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21222981255310</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442134365100</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442156523250</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442145442818.9583</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254331214578</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254334085262</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">20781887896940</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442156993950</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442178660650</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442167827594.4681</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">47</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254334085262</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254336955947</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21225129132600</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442179133270</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442201248030</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442190190262.5000</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254336955947</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254339826631</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21226213026150</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442201720960</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442223827720</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442212771378.1250</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254339826631</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254342697316</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21227293251850</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442224296570</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442246191720</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442235276080.2083</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254342697316</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254345568000</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21228371431870</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442246663300</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442268791290</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442257738163.9583</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254345568000</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254348438684</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21229455531730</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442269262370</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442291404770</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442280323577.7083</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254348438684</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254351309369</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">20788226878750</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442291875550</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442313515300</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442302699547.8723</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">47</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254351309369</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254354180053</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21231576621020</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442313990190</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442333971060</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442324512937.9167</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254354180053</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254357050738</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21232474653460</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442334346060</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442352121880</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442343221947.0833</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254357050738</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254359921422</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21233360433480</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442352500510</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442371671120</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442361675697.5000</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254359921422</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254362792107</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21234392588940</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442372144460</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442394227610</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442383178936.2500</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254362792107</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254365662791</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21235472883050</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442394698990</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442416721710</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442405685063.5417</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254365662791</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254368533476</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21236557207050</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442417196420</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442439347780</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442428275146.8750</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254368533476</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254371404160</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">20795177199970</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442439809050</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442461261420</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442450578722.7660</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">47</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254371404160</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254374274844</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21238693926960</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442461733210</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442483851610</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442472790145.0000</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254374274844</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254377145529</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">|</span>                    <span style="color: #cc66cc;">73</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">21239778454900</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442484323030</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442506442450</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">442495384477.0833</span> <span style="color: #66cc66;">|</span>         <span style="color: #cc66cc;">48</span> <span style="color: #66cc66;">|</span> <span style="color: #cc66cc;">1254377145529</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1254380016213</span> <span style="color: #66cc66;">|</span></pre></div></div>

<p>We can see how many rows have actually been aggregated in to the interval too (scroll to the right) - so that we can decide if there were enough intervals during the first row to be a good enough average (sometimes the first and last intervals may not be, and should perhaps be discarded), and the the interval that each row is computed for, i.e &#8220;1254325473209 - 1254328343893&#8243;</p>
<p>And a little verification:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> 
    <span style="color: #66cc66;">-&gt;</span>   <span style="color: #993333; font-weight: bold;">FROM</span> dc_ng_long_now 
    <span style="color: #66cc66;">-&gt;</span>  <span style="color: #993333; font-weight: bold;">WHERE</span> instance_attribute_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">73</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">76</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">77</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">79</span><span style="color: #66cc66;">&#41;</span> 
    <span style="color: #66cc66;">-&gt;</span>    <span style="color: #993333; font-weight: bold;">AND</span> end_time <span style="color: #993333; font-weight: bold;">BETWEEN</span> @start_time <span style="color: #993333; font-weight: bold;">AND</span> @end_time;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #66cc66;">|</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #66cc66;">|</span>   <span style="color: #cc66cc;">172240</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #cc66cc;">1</span> row <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0.12</span> sec<span style="color: #66cc66;">&#41;</span>
&nbsp;
mysql<span style="color: #66cc66;">&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">FROM</span><span style="color: #66cc66;">&#40;</span>
    <span style="color: #66cc66;">-&gt;</span> <span style="color: #993333; font-weight: bold;">SELECT</span> instance_attribute_id<span style="color: #66cc66;">,</span> 
    <span style="color: #66cc66;">-&gt;</span>        MIN<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">-&gt;</span>        MAX<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">-&gt;</span>        AVG<span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
    <span style="color: #66cc66;">-&gt;</span>        CONCAT<span style="color: #66cc66;">&#40;</span> ROUND<span style="color: #66cc66;">&#40;</span>FLOOR<span style="color: #66cc66;">&#40;</span> end_time <span style="color: #66cc66;">/</span>  @intervals<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>  @intervals<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">' - '</span><span style="color: #66cc66;">,</span> 
    <span style="color: #66cc66;">-&gt;</span>                ROUND<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span> FLOOR<span style="color: #66cc66;">&#40;</span> end_time <span style="color: #66cc66;">/</span>  @intervals <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span>  @intervals<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">AS</span> time_range
    <span style="color: #66cc66;">-&gt;</span>   <span style="color: #993333; font-weight: bold;">FROM</span> dc_ng_long_now 
    <span style="color: #66cc66;">-&gt;</span>  <span style="color: #993333; font-weight: bold;">WHERE</span> instance_attribute_id <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">73</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">76</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">77</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">79</span><span style="color: #66cc66;">&#41;</span> 
    <span style="color: #66cc66;">-&gt;</span>    <span style="color: #993333; font-weight: bold;">AND</span> end_time <span style="color: #993333; font-weight: bold;">BETWEEN</span> @start_time <span style="color: #993333; font-weight: bold;">AND</span> @end_time
    <span style="color: #66cc66;">-&gt;</span>  <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> instance_attribute_id<span style="color: #66cc66;">,</span> time_range
    <span style="color: #66cc66;">-&gt;</span> <span style="color: #66cc66;">&#41;</span> s1;
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #66cc66;">|</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #66cc66;">|</span>     <span style="color: #cc66cc;">3604</span> <span style="color: #66cc66;">|</span> 
<span style="color: #66cc66;">+</span><span style="color: #808080; font-style: italic;">----------+</span>
<span style="color: #cc66cc;">1</span> row <span style="color: #993333; font-weight: bold;">IN</span> <span style="color: #993333; font-weight: bold;">SET</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1.01</span> sec<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Note, I&#8217;m getting 4 sets of 901 rows, in the above case I&#8217;m getting roughly a 48 to 1 compression ratio for a month of data - going from <strong>172,240</strong> rows to <strong>3604!</strong>. </p>
<p>For MEM, there&#8217;s still work to do, but we&#8217;re on a roll now! Hopefully graph performance will be greatly improved in coming versions! <img src='http://www.markleith.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=290</wfw:commentRss>
		</item>
		<item>
		<title>MySQL University Session - Customizing MySQL Enterprise Monitor</title>
		<link>http://www.markleith.co.uk/?p=285</link>
		<comments>http://www.markleith.co.uk/?p=285#comments</comments>
		<pubDate>Wed, 09 Sep 2009 14:28:24 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=285</guid>
		<description><![CDATA[Just a quick note to let the masses know that I will be hosting a MySQL University session tomorrow, based on the talk that I gave at the MySQL UC in April - Customizing MySQL Enterprise Monitor.
It will be at 14:00 UTC - so if you are at all interested in MEM, and want to know [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to let the masses know that I will be hosting a <a title="MySQL University" href="http://forge.mysql.com/wiki/MySQL_University" target="_blank">MySQL University</a> session tomorrow, based on the talk that I gave at the MySQL UC in April - <a title="Customizing MySQL Enterprise Monitor" href="http://forge.mysql.com/wiki/Customizing_MySQL_Enterprise_Monitor" target="_blank">Customizing MySQL Enterprise Monitor</a>.</p>
<p>It will be at 14:00 UTC - so if you are at all interested in MEM, and want to know how to bend it towards your needs, then come along! I&#8217;ll see you there.</p>
<p><strong>EDIT: </strong>OOOPS, it&#8217;s 13:00 UTC</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=285</wfw:commentRss>
		</item>
		<item>
		<title>SHOW RELAYLOG EVENTS</title>
		<link>http://www.markleith.co.uk/?p=281</link>
		<comments>http://www.markleith.co.uk/?p=281#comments</comments>
		<pubDate>Fri, 26 Jun 2009 11:56:28 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[MySQL 5.4]]></category>

		<category><![CDATA[replication]]></category>

		<category><![CDATA[SHOW statements]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=281</guid>
		<description><![CDATA[I reported a bug about SHOW BINLOG EVENTS not working with relay logs a couple of years ago - Bug #28777.
It&#8217;s now been fixed in MySQL 5.4, by adding a new SHOW statement - SHOW RELAYLOG EVENTS.
The replication team are really hammering through things at the moment - Kudos!
]]></description>
			<content:encoded><![CDATA[<p>I reported a bug about SHOW BINLOG EVENTS not working with relay logs a couple of years ago - <a href="http://bugs.mysql.com/bug.php?id=28777">Bug #28777</a>.</p>
<p>It&#8217;s now been fixed in <a href="http://dev.mysql.com/downloads/mysql/5.4.html">MySQL 5.4</a>, by adding a new SHOW statement - <a href="http://dev.mysql.com/doc/refman/5.4/en/show-relaylog-events.html">SHOW RELAYLOG EVENTS</a>.</p>
<p>The replication team are really hammering through things at the moment - Kudos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=281</wfw:commentRss>
		</item>
		<item>
		<title>Past Presentations Now Online</title>
		<link>http://www.markleith.co.uk/?p=271</link>
		<comments>http://www.markleith.co.uk/?p=271#comments</comments>
		<pubDate>Tue, 16 Jun 2009 10:04:15 +0000</pubDate>
		<dc:creator>Mark Leith</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[INFORMATION_SCHEMA]]></category>

		<category><![CDATA[MEM]]></category>

		<category><![CDATA[Oracle]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://www.markleith.co.uk/?p=271</guid>
		<description><![CDATA[I uploaded all of my past presentations to Slideshare recently, and realized that I hadn&#8217;t actually posted some of these on my blog in the past as well. 
So I&#8217;ve created a new Presentations Page that has all of these together now. 
It&#8217;s kind of funny to see the &#8220;MySQL for Oracle DBAs&#8221; presentation again [...]]]></description>
			<content:encoded><![CDATA[<p>I uploaded all of my past presentations to <a href="http://www.slideshare.net/Leithal/slideshows">Slideshare</a> recently, and realized that I hadn&#8217;t actually posted some of these on my blog in the past as well. </p>
<p>So I&#8217;ve created a new <a href="http://www.markleith.co.uk/?page_id=262">Presentations Page</a> that has all of these together now. </p>
<p>It&#8217;s kind of funny to see the &#8220;MySQL for Oracle DBAs&#8221; presentation again - a lot has changed since 2006! </p>
<p>In any case, enjoy if you haven&#8217;t seen them - give them a look over if interested, and feel free to post comments or questions on the page!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markleith.co.uk/?feed=rss2&amp;p=271</wfw:commentRss>
		</item>
	</channel>
</rss>
