<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elphin &#187; MySQL</title>
	<atom:link href="http://www.elphin.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elphin.com</link>
	<description>Making fine software since 1998</description>
	<lastBuildDate>Sun, 09 Aug 2009 16:28:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Munin plugin for graphing MySQL slave delay</title>
		<link>http://www.elphin.com/2008/02/munin-plugin-for-graphing-mysql-slave-delay/</link>
		<comments>http://www.elphin.com/2008/02/munin-plugin-for-graphing-mysql-slave-delay/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 11:41:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.dixo.net/2008/02/10/munin-plugin-for-graphing-mysql-slave-delay/</guid>
		<description><![CDATA[I wanted to track the delay of a mysql slave server in Munin, and found nothing appropriate after a quick google. So, in case anyone else finds it useful, here is a plugin which will allow you to do just that.
Here&#8217;s a typical graph:

Download:  mysql_slave (1 Kb)
EDIT: I wrote this so I could better [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to track the delay of a mysql slave server in <a href="http://munin.sourceforge.net/">Munin</a>, and found nothing appropriate after a quick google. So, in case anyone else finds it useful, here is a plugin which will allow you to do just that.</p>
<p>Here&#8217;s a typical graph:</p>
<p><img src='http://www.elphin.com/wp-content/uploads/2008/02/slavedelay.png' alt='Slave Delay Graph' /></p>
<p>Download:  <a href="http://blog.dixo.net/mysql_slave">mysql_slave</a> (1 Kb)</p>
<p>EDIT: I wrote this so I could better understand the recovery time of a slave which had 13 hours of updates to catch up on. While it was good for that, it&#8217;s less useful for the day-to-day lag as munin will only be polling it every 5 minutes. A better way would be to use <a href="http://maatkit.sourceforge.net/doc/mk-heartbeat.html">mk-heartbeat</a> to get a more accurate moving average.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elphin.com/2008/02/munin-plugin-for-graphing-mysql-slave-delay/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL gotcha using BETWEEN with dates</title>
		<link>http://www.elphin.com/2007/11/mysql-gotcha-using-between-with-dates/</link>
		<comments>http://www.elphin.com/2007/11/mysql-gotcha-using-between-with-dates/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 12:47:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.dixo.net/2007/11/16/mysql-gotcha-using-between-with-dates/</guid>
		<description><![CDATA[We just updated a development server from Ubuntu 6.06 to 6.10. As a result, MySQL went up a couple of point releases from 5.0.22 to 5.0.24a.
Suddenly, the web application we were working on stopped working. It wasn&#8217;t possible to log in.
We quickly narrowed it down to a clause in query which checked a users subscription [...]]]></description>
			<content:encoded><![CDATA[<p>We just updated a development server from Ubuntu 6.06 to 6.10. As a result, MySQL went up a couple of point releases from 5.0.22 to 5.0.24a.</p>
<p>Suddenly, the web application we were working on stopped working. It wasn&#8217;t possible to log in.</p>
<p>We quickly narrowed it down to a clause in query which checked a users subscription was valid by checking its start and end dates. It looked  bit like this:</p>
<pre>
SELECT foo FROM bar WHERE NOW() BETWEEN start AND end;
</pre>
<p>MySQL 5.0.22 returned rows, but 5.0.24 didn&#8217;t. After scratching our heads, I checked <a href="http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_between">the manual:</a></p>
<blockquote><p>For best results when using BETWEEN with date or time values, you should use CAST() to explicitly convert the values to the desired data type. Examples: If you compare a DATETIME to two DATE values, convert the DATE values to DATETIME values. If you use a string constant such as &#8216;2001-1-1&#8242; in a comparison to a DATE, cast the string to a DATE.</p></blockquote>
<p>The phrase &#8220;best results&#8221; make it sound like we&#8217;re baking a cake, and that your query results will be fluffier and more flavoursome if you use CAST! What they actually mean is, if you&#8217;re comparing different date types, you&#8217;re screwed if you don&#8217;t cast. You might get nothing.</p>
<p>Sure enough, our start and end columns were dates, and using cast in the query worked just fine:</p>
<pre>
SELECT foo FROM bar WHERE <b>CAST(NOW() AS DATE)</b>  BETWEEN start AND end;
</pre>
<p>I couldn&#8217;t find anything directly related to this change in behaviour in the changelogs, but hopefully this will help someone out there&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.elphin.com/2007/11/mysql-gotcha-using-between-with-dates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
