<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.1" -->
<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/"
	>

<channel>
	<title>The Rhodium Toad</title>
	<link>http://blog.rhodiumtoad.org.uk</link>
	<description>an experimental blog</description>
	<pubDate>Sun, 08 Mar 2009 04:17:26 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>
	<language>en</language>
			<item>
		<title>Selecting random rows from a table</title>
		<link>http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/</link>
		<comments>http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 04:17:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
		
		<category><![CDATA[PlanetPG]]></category>

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

		<guid isPermaLink="false">http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/</guid>
		<description><![CDATA[The question of how to select some random items from a table is one that comes up fairly often in the IRC channel (and as the subject of blog posts, such as this one from depesz).
While there is a simple solution of this form (let&#8217;s assume for now that we want to select 5 uniformly [...]]]></description>
			<content:encoded><![CDATA[<p>The question of how to select some random items from a table is one that comes up fairly often in the IRC channel (and as the subject of blog posts, such as <a href="http://www.depesz.com/index.php/2007/09/16/my-thoughts-on-getting-random-row/">this</a> one from depesz).<br />
While there is a simple solution of this form (let&#8217;s assume for now that we want to select 5 uniformly random rows from table &#8220;items&#8221;):</p>
<blockquote><p><code>
<pre>select * from items order by random() limit 5;
</pre>
<p></code></p></blockquote>
<p>this is unfortunately slow if the table has more than a small number of rows. It is possible to do far better, though there aren&#8217;t really any perfect solutions that don&#8217;t resort to procedural logic in some way. Let&#8217;s start by looking at how to do better in plain SQL.<br />
 <a href="http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/#more-6" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rhodiumtoad.org.uk/2009/03/08/selecting-random-rows-from-a-table/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reading XML files into the database</title>
		<link>http://blog.rhodiumtoad.org.uk/2009/02/05/reading-xml-files-into-the-database/</link>
		<comments>http://blog.rhodiumtoad.org.uk/2009/02/05/reading-xml-files-into-the-database/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 12:09:51 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
		
		<category><![CDATA[PlanetPG]]></category>

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

		<guid isPermaLink="false">http://blog.rhodiumtoad.org.uk/2009/02/05/reading-xml-files-into-the-database/</guid>
		<description><![CDATA[This came up as a question on IRC: how to read an XML file on the server into a table column?
]]></description>
			<content:encoded><![CDATA[<p>This came up as a question on IRC: how to read an XML file on the server into a table column?</p>
<p> <a href="http://blog.rhodiumtoad.org.uk/2009/02/05/reading-xml-files-into-the-database/#more-5" class="more-link">(more&#8230;)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rhodiumtoad.org.uk/2009/02/05/reading-xml-files-into-the-database/feed/</wfw:commentRss>
		</item>
		<item>
		<title>UUID generation for PostgreSQL 8.3 on FreeBSD</title>
		<link>http://blog.rhodiumtoad.org.uk/2008/12/21/uuid-generation-for-postgresql-83-on-freebsd/</link>
		<comments>http://blog.rhodiumtoad.org.uk/2008/12/21/uuid-generation-for-postgresql-83-on-freebsd/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 20:49:52 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
		
		<category><![CDATA[PlanetPG]]></category>

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

		<guid isPermaLink="false">http://blog.rhodiumtoad.org.uk/2008/12/21/uuid-generation-for-postgresql-83-on-freebsd/</guid>
		<description><![CDATA[A couple of weeks ago I whomped up a quick module in response to someone on IRC who was unable to get contrib/uuid-ossp working on FreeBSD (which turns out to be due to a nasty conflict between misc/ossp-uuid and libc).
I&#8217;ve now put it up on PGFoundry, and the initial release can be found here:
http://pgfoundry.org/projects/uuid-freebsd/
]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I whomped up a quick module in response to someone on IRC who was unable to get contrib/uuid-ossp working on FreeBSD (which turns out to be due to a nasty conflict between misc/ossp-uuid and libc).</p>
<p>I&#8217;ve now put it up on PGFoundry, and the initial release can be found here:</p>
<p><a href="http://pgfoundry.org/projects/uuid-freebsd/" target="_blank">http://pgfoundry.org/projects/uuid-freebsd/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rhodiumtoad.org.uk/2008/12/21/uuid-generation-for-postgresql-83-on-freebsd/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On Normalization</title>
		<link>http://blog.rhodiumtoad.org.uk/2008/12/08/on-normalization/</link>
		<comments>http://blog.rhodiumtoad.org.uk/2008/12/08/on-normalization/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 03:52:06 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
		
		<category><![CDATA[PlanetPG]]></category>

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

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

		<guid isPermaLink="false">http://blog.rhodiumtoad.org.uk/2008/12/08/on-normalization/</guid>
		<description><![CDATA[People have funny ideas about database normalization.
What normalization is not:

creating an (id,value) table for every single piece of data is not normalization
using surrogate keys for everything is not normalization
a way to improve performance (though it sometimes does)

Equally, failing to do the above does not mean your data is &#8220;denormalized&#8221;.
What normalization is:

keeping your data consistent by [...]]]></description>
			<content:encoded><![CDATA[<p>People have funny ideas about database normalization.</p>
<p><strong>What normalization is not:</strong></p>
<ul>
<li>creating an (id,value) table for every single piece of data is not normalization</li>
<li>using surrogate keys for everything is not normalization</li>
<li>a way to improve performance (though it sometimes does)</li>
</ul>
<p>Equally, failing to do the above does not mean your data is &#8220;denormalized&#8221;.</p>
<p><strong>What normalization is:</strong></p>
<ul>
<li>keeping your data consistent by ensuring that the relationships between values exist only in one place</li>
<li>applying the rules: <a href="http://en.wikipedia.org/wiki/1NF">1NF</a>, <a href="http://en.wikipedia.org/wiki/2NF">2NF</a>, <a href="http://en.wikipedia.org/wiki/3NF">3NF</a>, <a href="http://en.wikipedia.org/wiki/BCNF">BCNF</a>, <a href="http://en.wikipedia.org/wiki/4NF">4NF</a>, <a href="http://en.wikipedia.org/wiki/5NF">5NF</a> &#8230; usually between 3NF and 4NF is enough</li>
</ul>
<p>Obviously, though, there are times when one denormalizes for performance reasons, with appropriate care to ensure consistency isn&#8217;t lost in the process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rhodiumtoad.org.uk/2008/12/08/on-normalization/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://blog.rhodiumtoad.org.uk/2008/12/08/hello-world/</link>
		<comments>http://blog.rhodiumtoad.org.uk/2008/12/08/hello-world/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 00:12:38 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
		
		<category><![CDATA[Bloggery]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I have no idea if I want to keep a blog.
So let&#8217;s see what happens, if anything.
]]></description>
			<content:encoded><![CDATA[<p>I have no idea if I want to keep a blog.</p>
<p>So let&#8217;s see what happens, if anything.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rhodiumtoad.org.uk/2008/12/08/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
