<?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>Robin Clarke - Perl and Life</title>
	<atom:link href="http://www.robinclarke.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robinclarke.net</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Tue, 06 Jan 2009 23:43:27 +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>Amazon can&#8217;t do math</title>
		<link>http://www.robinclarke.net/2009/01/07/amazon-cant-do-math/</link>
		<comments>http://www.robinclarke.net/2009/01/07/amazon-cant-do-math/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 23:17:27 +0000</pubDate>
		<dc:creator>robin</dc:creator>
		
		<category><![CDATA[Internet]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.robinclarke.net/?p=49</guid>
		<description><![CDATA[I guess even the big boys make mistakes&#8230; I was just checking out a product at Amazon to see what delivery to Canada would be, and at the final stage in the checkout, I had the option to view in EUR or USD.  Can anyone tell me what&#8217;s wrong here?

That&#8217;s right! 7.85+6.98=14.83, not 16.24!  Yes [...]]]></description>
			<content:encoded><![CDATA[<p>I guess even the big boys make mistakes&#8230; I was just checking out a product at Amazon to see what delivery to Canada would be, and at the final stage in the checkout, I had the option to view in EUR or USD.  Can anyone tell me what&#8217;s wrong here?</p>
<p><img class="aligncenter size-full wp-image-50" title="Amazon error" src="http://www.robinclarke.net/wp-content/uploads/2009/01/amazon_error.gif" alt="Amazon error" width="392" height="302" /></p>
<p>That&#8217;s right! 7.85+6.98=14.83, not 16.24!  Yes - the totals at the end are similar, and it seems that the Import Fees Deposit have already been added at &#8220;Total Before Tax&#8221; (but with a terrible exchange rate!), but still&#8230; what shoddy programming!</p>
<p>I&#8217;ve tried posting this to Amazon, but it&#8217;s impossible to send them an email without an order number&#8230; anybody have friends at Amazon?  Maybe they&#8217;d be interested to know about this bug&#8230; I&#8217;ll do consulting if they need help!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robinclarke.net/2009/01/07/amazon-cant-do-math/feed/</wfw:commentRss>
		</item>
		<item>
		<title>View and Union very slow</title>
		<link>http://www.robinclarke.net/2008/12/11/view-and-union-very-slow/</link>
		<comments>http://www.robinclarke.net/2008/12/11/view-and-union-very-slow/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 00:07:22 +0000</pubDate>
		<dc:creator>robin</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

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

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

		<guid isPermaLink="false">http://www.robinclarke.net/?p=42</guid>
		<description><![CDATA[I&#8217;ve found quite a few articles like this one from MySQL selling views as the perfect way to join archive data with live data to provide seamless access.
What I wanted: keep archive data in a compact, non modifiable table (I chose packed MyISAM tables), and live data in a transactional table (I chose InnoDB), possibly [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found quite a few articles like <a title="Federated tables" href="http://dev.mysql.com/tech-resources/articles/mysql-federated-storage.html" target="_blank">this one </a>from MySQL selling views as the perfect way to join archive data with live data to provide seamless access.</p>
<p>What I wanted: keep archive data in a compact, non modifiable table (I chose packed MyISAM tables), and live data in a transactional table (I chose InnoDB), possibly even on two different machines.  I was thrilled when I found the article linked above, with the sweet idea how to create a view which would combine both, and imagined that while it would make a performance hit, it shouldn&#8217;t be that bad, because the data in the packed, optimised MyISAM tables should have much faster access than the InnoDB, and given that the volume of the data is in there, and all select conditions are on indexed columns, it should be pretty fast.</p>
<p>WRONG!</p>
<p>Views using a UNION are very poorly optimised, and create complete temporary tables before matching any where conditions.  Even on a COUNT(*) which should not even require /any/ data to be retreived, it took significantly longer.</p>
<p>Here by example:</p>
<p>Get the sample employees database <a title="Sample database" href="https://launchpad.net/test-db/employees-db-1/1.0.5" target="_blank">here</a>, and load it.</p>
<p>Create a test database, and a salaries table in it:</p>
<pre>(root@127.0.0.1) [employees]&gt;CREATE DATABASE `test`;
(root@127.0.0.1) [employees]&gt;CREATE TABLE `test`.`salaries` (
  `emp_no` int(11) NOT NULL,
  `salary` int(11) NOT NULL,
  `from_date` date NOT NULL,
  `to_date` date NOT NULL,
  PRIMARY KEY (`emp_no`,`from_date`),
  KEY `emp_no` (`emp_no`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
<p>Then split the table salaries:</p>
<pre>(root@127.0.0.1) [employees]&gt;INSERT INTO `test`.`salaries` SELECT * FROM `employees`.`salaries` WHERE emp_no&lt;242293;</pre>
<pre>(root@127.0.0.1) [employees]&gt;DELETE FROM `employees`.`salaries` WHERE emp_no&lt;242293;</pre>
<p>How long does it take to count each one?</p>
<pre>(root@127.0.0.1) [employees]&gt;SELECT SQL_NO_CACHE COUNT(*) FROM `employees`.`salaries`;</pre>
<pre>+----------+</pre>
<pre>| COUNT(*) |</pre>
<pre>+----------+</pre>
<pre>|  1492975 |</pre>
<pre>+----------+</pre>
<pre>1 row in set (0.30 sec)</pre>
<pre>(root@127.0.0.1) [employees]&gt;SELECT SQL_NO_CACHE COUNT(*) FROM `test`.`salaries`;</pre>
<pre>+----------+</pre>
<pre>| COUNT(*) |</pre>
<pre>+----------+</pre>
<pre>|  1351072 |</pre>
<pre>+----------+</pre>
<pre>1 row in set (0.29 sec)</pre>
<p>That&#8217;s ok, and we see from the explain that it is indeed using a SIMPLE select, using the index on epm_no:</p>
<pre>(root@127.0.0.1) [employees]&gt;EXPLAIN SELECT SQL_NO_CACHE COUNT(*) FROM `test`.`salaries`;</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+-------------+</pre>
<pre>| id | select_type | table    | type  | possible_keys | key    | key_len | ref  | rows    | Extra       |</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+-------------+</pre>
<pre>|  1 | SIMPLE      | salaries | index | NULL          | emp_no | 4       | NULL | 1351439 | Using index |</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+-------------+</pre>
<pre>1 row in set (0.01 sec)</pre>
<p>So let&#8217;s make a view and join the tables, and try that again on the view:</p>
<pre>(root@127.0.0.1) [employees]&gt;CREATE VIEW salaries_all AS SELECT * FROM `employees`.`salaries` UNION ALL SELECT * FROM `test`.`salaries`;</pre>
<pre>(root@127.0.0.1) [employees]&gt;EXPLAIN SELECT SQL_NO_CACHE COUNT(*) FROM `employees`.`salaries_all`;
+----+--------------+------------+------+---------------+------+---------+------+---------+------------------------------+
| id | select_type  | table      | type | possible_keys | key  | key_len | ref  | rows    | Extra                        |
+----+--------------+------------+------+---------------+------+---------+------+---------+------------------------------+
|  1 | PRIMARY      | NULL       | NULL | NULL          | NULL | NULL    | NULL |    NULL | Select tables optimized away |
|  2 | DERIVED      | salaries   | ALL  | NULL          | NULL | NULL    | NULL | 2713588 |                              |
|  3 | UNION        | salaries   | ALL  | NULL          | NULL | NULL    | NULL | 1351439 |                              |
| NULL | UNION RESULT | &lt;union2,3&gt; | ALL  | NULL          | NULL | NULL    | NULL |    NULL |                              |
+----+--------------+------------+------+---------------+------+---------+------+---------+------------------------------+
4 rows in set (9.85 sec)</pre>
<p>Oh my god!</p>
<p>Even a query with sub-queries is faster by a factor of 20!</p>
<pre>(root@127.0.0.1) [employees]&gt;SELECT SQL_NO_CACHE ( SELECT COUNT(*) FROM `test`.`salaries` ) + ( SELECT COUNT(*) FROM `employees`.`salaries` );</pre>
<pre>+----------------------------------------------------------------------------------------------+</pre>
<pre>| ( SELECT COUNT(*) FROM `test`.`salaries` ) + ( SELECT COUNT(*) FROM `employees`.`salaries` ) |</pre>
<pre>+----------------------------------------------------------------------------------------------+</pre>
<pre>|                                                                                      2844047 |</pre>
<pre>+----------------------------------------------------------------------------------------------+</pre>
<pre>1 row in set (0.56 sec)</pre>
<pre>(root@127.0.0.1) [employees]&gt;EXPLAIN SELECT SQL_NO_CACHE ( SELECT COUNT(*) FROM `test`.`salaries` ) + ( SELECT COUNT(*) FROM `employees`.`salaries` );</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+----------------+</pre>
<pre>| id | select_type | table    | type  | possible_keys | key    | key_len | ref  | rows    | Extra          |</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+----------------+</pre>
<pre>|  1 | PRIMARY     | NULL     | NULL  | NULL          | NULL   | NULL    | NULL |    NULL | No tables used |</pre>
<pre>|  3 | SUBQUERY    | salaries | index | NULL          | emp_no | 4       | NULL | 2713588 | Using index    |</pre>
<pre>|  2 | SUBQUERY    | salaries | index | NULL          | emp_no | 4       | NULL | 1351439 | Using index    |</pre>
<pre>+----+-------------+----------+-------+---------------+--------+---------+------+---------+----------------+</pre>
<pre>3 rows in set (0.00 sec)</pre>
<p>I guess for now I&#8217;ll have to wait till views are optimised before I can use them like this&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robinclarke.net/2008/12/11/view-and-union-very-slow/feed/</wfw:commentRss>
		</item>
		<item>
		<title>No prior art there John Montagu!</title>
		<link>http://www.robinclarke.net/2008/11/25/no-prior-art-there-john-montagu/</link>
		<comments>http://www.robinclarke.net/2008/11/25/no-prior-art-there-john-montagu/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 17:54:37 +0000</pubDate>
		<dc:creator>robin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.robinclarke.net/?p=40</guid>
		<description><![CDATA[John Montagu (the 4th Earl of Sandwich) is generally credited as being the inventor of the sandwich, or at least the concept of two pieces of bread with filling between them was made popular by him.  Now, almost 300 years later, McDonalds wants to patent the process!  If they receive the patent, say goodbye to [...]]]></description>
			<content:encoded><![CDATA[<p>John Montagu (the 4th Earl of Sandwich) is <a title="Sandwich" href="http://en.wikipedia.org/wiki/Sandwich" target="_blank">generally credited</a> as being the inventor of the sandwich, or at least the concept of two pieces of bread with filling between them was made popular by him.  Now, almost 300 years later, <a title="idiotic patent application" href="href=&quot;http://www.wipo.int/pctdb/en/wo.jsp?IA=US2005044838&amp;WO=2006068865&amp;DISPLAY=STATUS" target="_blank">McDonalds wants to patent the process</a>!  If they receive the patent, say goodbye to your tasty BLT butties at the corner deli, and close the curtains when you make a sandwich in the kitchen, because the Big-M wants (more) of your money!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robinclarke.net/2008/11/25/no-prior-art-there-john-montagu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Logitech QuickCam Pro 9000 review</title>
		<link>http://www.robinclarke.net/2008/11/11/logitech-quickcam-pro-9000-review/</link>
		<comments>http://www.robinclarke.net/2008/11/11/logitech-quickcam-pro-9000-review/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 22:39:30 +0000</pubDate>
		<dc:creator>robin</dc:creator>
		
		<category><![CDATA[Reviews]]></category>

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

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

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

		<guid isPermaLink="false">http://www.robinclarke.net/?p=36</guid>
		<description><![CDATA[With Ubuntu 8.10 (Intrepid Ibex), this (slightly pricy - about 50EUR) webcam ran right out of the box (the standard UVC driver was used - I didn&#8217;t have to do a thing).  Image quality is super, as is light sensitivity, and (in contrast to many of the cheapo webcams like ASUS ICAM320 Webcam 640X480, which [...]]]></description>
			<content:encoded><![CDATA[<p>With Ubuntu 8.10 (Intrepid Ibex), this (slightly pricy - about 50EUR) webcam ran right out of the box (the standard UVC driver was used - I didn&#8217;t have to do a thing).  Image quality is super, as is light sensitivity, and (in contrast to many of the cheapo webcams like <span class="listing">ASUS ICAM320 Webcam 640X480, which I tried out as well), there is no abnormal CPU load when the webcam is running!  I&#8217;ve tried it with Skype and Co. already.  I like it!<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.robinclarke.net/2008/11/11/logitech-quickcam-pro-9000-review/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Arrived in Vancouver</title>
		<link>http://www.robinclarke.net/2008/10/22/arrived-in-vancouver/</link>
		<comments>http://www.robinclarke.net/2008/10/22/arrived-in-vancouver/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 21:28:52 +0000</pubDate>
		<dc:creator>robin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.robinclarke.net/?p=34</guid>
		<description><![CDATA[I&#8217;ve arrived in Vancouver!  Actually I&#8217;ve been here a week already, and the first while was rather busy&#8230; but we&#8217;ve got ourselves sorted out a bit now, and even found time to upload some pictures and write some reports
Keep reading there for the latest news and stories of our holiday and new life in Vancouver!
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve arrived in Vancouver!  Actually I&#8217;ve been here a week already, and the first while was rather busy&#8230; but we&#8217;ve got ourselves sorted out a bit now, and even found time to <a title="As orange as always" href="http://www.as-orange-as-always.com/" target="_blank">upload some pictures and write some reports</a></p>
<p>Keep reading there for the latest news and stories of our holiday and new life in Vancouver!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.robinclarke.net/2008/10/22/arrived-in-vancouver/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
