<?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: Pull random data out of MySQL without making it cry &#8211; using and optimizing ORDER BY, LIMIT, OFFSET etc.</title>
	<atom:link href="http://mihasya.com/blog/pull-random-data-out-of-mysql-without-making-it-cry-using-and-optimizing-order-by-limit-offset-etc/feed/" rel="self" type="application/rss+xml" />
	<link>http://mihasya.com/blog/pull-random-data-out-of-mysql-without-making-it-cry-using-and-optimizing-order-by-limit-offset-etc/</link>
	<description>good things now come in packages of three</description>
	<lastBuildDate>Sat, 23 Jul 2011 22:40:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: mihasya</title>
		<link>http://mihasya.com/blog/pull-random-data-out-of-mysql-without-making-it-cry-using-and-optimizing-order-by-limit-offset-etc/comment-page-1/#comment-3303</link>
		<dc:creator>mihasya</dc:creator>
		<pubDate>Sat, 26 Sep 2009 17:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://mihasya.com/blog/?p=297#comment-3303</guid>
		<description>&lt;p&gt;That seems like it would probably give you &quot;more random&quot; data, which is good. However, it would be more expensive. It would seem you&#039;d have to build that table the first time you ran the query (could take a while if your table is large, even though it&#039;s in memory), then maintain it on every insert/delete, or rebuild it periodically.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>That seems like it would probably give you &#8220;more random&#8221; data, which is good. However, it would be more expensive. It would seem you&#8217;d have to build that table the first time you ran the query (could take a while if your table is large, even though it&#8217;s in memory), then maintain it on every insert/delete, or rebuild it periodically.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Malone</title>
		<link>http://mihasya.com/blog/pull-random-data-out-of-mysql-without-making-it-cry-using-and-optimizing-order-by-limit-offset-etc/comment-page-1/#comment-3274</link>
		<dc:creator>Mike Malone</dc:creator>
		<pubDate>Wed, 23 Sep 2009 17:25:39 +0000</pubDate>
		<guid isPermaLink="false">http://mihasya.com/blog/?p=297#comment-3274</guid>
		<description>&lt;p&gt;The other way I&#039;ve heard this being done is by building a &quot;random number table&quot; that you can join against. You&#039;d probably want to use a memory table for this, but the idea is that you create an (id, num) table, where id is the PK and num is some random number between your min and max ID. Once that&#039;s done you can choose a random offset in your random number table, set a limit, join to your real data table on num = real_data_id, and you&#039;ve got a random bit of data.&lt;/p&gt;

&lt;p&gt;Of course I&#039;ve never actually tried this in production anywhere, and I can&#039;t remember where I heard about this tactic, but aside from the join it seems just clever enough to work.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The other way I&#8217;ve heard this being done is by building a &#8220;random number table&#8221; that you can join against. You&#8217;d probably want to use a memory table for this, but the idea is that you create an (id, num) table, where id is the PK and num is some random number between your min and max ID. Once that&#8217;s done you can choose a random offset in your random number table, set a limit, join to your real data table on num = real_data_id, and you&#8217;ve got a random bit of data.</p>

<p>Of course I&#8217;ve never actually tried this in production anywhere, and I can&#8217;t remember where I heard about this tactic, but aside from the join it seems just clever enough to work.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

