<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: &#8220;Order By&#8221; in SQL queries and random selection of database items</title>
	<atom:link href="http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/</link>
	<description>The Science of Web Art, Design and Development</description>
	<pubDate>Tue, 06 Jan 2009 23:45:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: guioconnor</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-1030</link>
		<dc:creator>guioconnor</dc:creator>
		<pubDate>Fri, 18 Jan 2008 08:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-1030</guid>
		<description>&lt;p&gt;@Benjamin Wilger - &lt;blockquote&gt;Nice article and thanks for the credit! (thank you, google!)
But it's not worth to give the credit to me since all that is written in the MySQL Manual ;-)&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;Hi, Ben. I wanted to drop you a line back when I wrote this post, but I couldn't find you around. Now, I think credit is due, it was a nice solution when showed it up :-)&lt;/p&gt;

&lt;blockquote&gt;A little hint for the ORDER BY rand() stuff (...) if you have a fairly big table (e.g. more than 1000 entries) you might get some performance problems.&lt;/blockquote&gt;

&lt;p&gt;Thanks for the additional hint!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Benjamin Wilger - <blockquote>Nice article and thanks for the credit! (thank you, google!)
But it&#8217;s not worth to give the credit to me since all that is written in the MySQL Manual ;-)</blockquote></p>

<p>Hi, Ben. I wanted to drop you a line back when I wrote this post, but I couldn&#8217;t find you around. Now, I think credit is due, it was a nice solution when showed it up :-)</p>

<blockquote>A little hint for the ORDER BY rand() stuff (&#8230;) if you have a fairly big table (e.g. more than 1000 entries) you might get some performance problems.</blockquote>

<p>Thanks for the additional hint!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Benjamin Wilger</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-1023</link>
		<dc:creator>Benjamin Wilger</dc:creator>
		<pubDate>Sun, 13 Jan 2008 13:23:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-1023</guid>
		<description>&lt;p&gt;Guten Tag!&lt;/p&gt;

&lt;p&gt;Nice article and thanks for the credit! (thank you, google!)
But it's not worth to give the credit to me since all that is written in the MySQL Manual ;-)&lt;/p&gt;

&lt;p&gt;A little hint for the ORDER BY rand() stuff: Keep in mind that MySQL optimizes LIMITed Queries. So if you say LIMIT 2 it will just &lt;em&gt;read&lt;/em&gt; two entries from the table unless you do an ORDER BY. If you order by an indexed column the job is simple for MySQL. But if you sort by a value produced by a function like rand(), MySQL is forced to do a full table scan to get all the rows. It then needs to copy the unsorted result to memory (if too big it writes them to hard disc) and sorts them. So if you have a fairly big table (e.g. more than 1000 entries) you might get some performance problems.&lt;/p&gt;

&lt;p&gt;Greetings,
Benjamin&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Guten Tag!</p>

<p>Nice article and thanks for the credit! (thank you, google!)
But it&#8217;s not worth to give the credit to me since all that is written in the MySQL Manual ;-)</p>

<p>A little hint for the ORDER BY rand() stuff: Keep in mind that MySQL optimizes LIMITed Queries. So if you say LIMIT 2 it will just <em>read</em> two entries from the table unless you do an ORDER BY. If you order by an indexed column the job is simple for MySQL. But if you sort by a value produced by a function like rand(), MySQL is forced to do a full table scan to get all the rows. It then needs to copy the unsorted result to memory (if too big it writes them to hard disc) and sorts them. So if you have a fairly big table (e.g. more than 1000 entries) you might get some performance problems.</p>

<p>Greetings,
Benjamin</p>]]></content:encoded>
	</item>
	<item>
		<title>By: guioconnor</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-473</link>
		<dc:creator>guioconnor</dc:creator>
		<pubDate>Tue, 07 Aug 2007 14:54:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-473</guid>
		<description>&lt;p&gt;@Andy - :-) I'm glad it has been useful&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Andy - :-) I&#8217;m glad it has been useful</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-470</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Tue, 07 Aug 2007 10:38:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-470</guid>
		<description>&lt;p&gt;Spot on with that last tip - thanks! The MySQl manual is not great and I was despairing of Google until now.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Spot on with that last tip - thanks! The MySQl manual is not great and I was despairing of Google until now.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: guioconnor</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-390</link>
		<dc:creator>guioconnor</dc:creator>
		<pubDate>Fri, 15 Jun 2007 10:44:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-390</guid>
		<description>&lt;p&gt;@Oda: That is indeed a useful link, I updated the article to include it. Thanks!&lt;/p&gt;

&lt;p&gt;@AndreYK: Great observation, thanks for sharing it.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Oda: That is indeed a useful link, I updated the article to include it. Thanks!</p>

<p>@AndreYK: Great observation, thanks for sharing it.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: AndreYK</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-389</link>
		<dc:creator>AndreYK</dc:creator>
		<pubDate>Thu, 14 Jun 2007 23:53:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-389</guid>
		<description>&lt;p&gt;I have a tip too ! It is very common to use GROUP BY queries. However, when we use it MySQL sorts the entries by default, spending some computational time. If you wish to optimize GROUP BY queries, it is interesting to not sort using ORDER BY NULL. See the link that Oda cited.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I have a tip too ! It is very common to use GROUP BY queries. However, when we use it MySQL sorts the entries by default, spending some computational time. If you wish to optimize GROUP BY queries, it is interesting to not sort using ORDER BY NULL. See the link that Oda cited.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: oda</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-388</link>
		<dc:creator>oda</dc:creator>
		<pubDate>Thu, 14 Jun 2007 21:00:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-388</guid>
		<description>&lt;p&gt;Hei! Very good article! The last example was indeed remarkable!&lt;/p&gt;

&lt;p&gt;MySQL is full of nice functions, take a look at:
http://dev.mysql.com/doc/refman/5.0/en/functions.html&lt;/p&gt;

&lt;p&gt;And don't forget: RTFM&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hei! Very good article! The last example was indeed remarkable!</p>

<p>MySQL is full of nice functions, take a look at:
<a href="http://dev.mysql.com/doc/refman/5.0/en/functions.html">http://dev.mysql.com/doc/refman/5.0/en/functions.html</a></p>

<p>And don&#8217;t forget: RTFM</p>]]></content:encoded>
	</item>
	<item>
		<title>By: guioconnor</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-387</link>
		<dc:creator>guioconnor</dc:creator>
		<pubDate>Thu, 14 Jun 2007 18:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-387</guid>
		<description>&lt;p&gt;Thanks Andre. I didn't know that either until some weeks ago :-)&lt;/p&gt;

&lt;p&gt;When I first saw it, it really expanded my mind.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks Andre. I didn&#8217;t know that either until some weeks ago :-)</p>

<p>When I first saw it, it really expanded my mind.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andre</title>
		<link>http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/comment-page-1/#comment-386</link>
		<dc:creator>Andre</dc:creator>
		<pubDate>Thu, 14 Jun 2007 18:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.z-oc.com/blog/2007/06/order-by-in-sql-queries-and-random-selection-of-database-items/#comment-386</guid>
		<description>&lt;p&gt;Very nice tips about "ORDER by". The last example was new to me, i have never thought about boolean formulas with "ORDER by" queries.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Very nice tips about &#8220;ORDER by&#8221;. The last example was new to me, i have never thought about boolean formulas with &#8220;ORDER by&#8221; queries.</p>]]></content:encoded>
	</item>
</channel>
</rss>
