<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-3069349063312276662.post8981556857198918385..comments</id><updated>2011-08-17T15:34:11.403+02:00</updated><category term='flash'/><category term='idea'/><category term='javascript'/><category term='small talk'/><category term='mysql'/><category term='apple'/><category term='random'/><category term='restful'/><category term='adobe'/><category term='dell'/><category term='nlp'/><category term='gutsy'/><category term='android'/><category term='gedit'/><category term='plugin'/><category term='python'/><category term='rails'/><category term='searching'/><category term='tomboy'/><category term='performance'/><category term='fun'/><category term='tagging'/><category term='ubuntu'/><category term='usability'/><category term='deskbar'/><category term='authorization'/><category term='database'/><category term='google'/><title type='text'>Comments on Ecstatic Thinking: Selecting random row from a table</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://robzon.aenima.pl/feeds/8981556857198918385/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html'/><author><name>Robert Nasiadek</name><uri>http://www.blogger.com/profile/06721470947386818024</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-2663008076844113940</id><published>2011-08-17T15:34:11.403+02:00</published><updated>2011-08-17T15:34:11.403+02:00</updated><title type='text'>I made a gem for selecting random records that per...</title><summary type='text'>I made a gem for selecting random records that performs much better than order by rand():&lt;br /&gt;&lt;br /&gt;https://github.com/spilliton/randumb</summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/2663008076844113940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/2663008076844113940'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1313588051403#c2663008076844113940' title=''/><author><name>Zac Kloepping</name><uri>http://www.blogger.com/profile/15722134933913649569</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1876094370'/></entry><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-4643425966482783365</id><published>2011-03-30T15:19:50.122+02:00</published><updated>2011-03-30T15:19:50.122+02:00</updated><title type='text'>the best solution is forget this and make money fi...</title><summary type='text'>the best solution is forget this and make money first with order rand()</summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/4643425966482783365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/4643425966482783365'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1301491190122#c4643425966482783365' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1134759345'/></entry><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-3993462853209717348</id><published>2008-12-01T21:11:00.000+01:00</published><updated>2008-12-01T21:11:00.000+01:00</updated><title type='text'>@bensonk: the other solution doesn't assume that I...</title><summary type='text'>@bensonk: the other solution doesn't assume that IDs are densely packed. It uses offset (limit), not ID number, so it chooses n-th found row, not a row with ID equal to n. So if you have IDs like 1, 2, 4, 8, and get 3 at random, this method will take 3rd row, which has ID = 4.</summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/3993462853209717348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/3993462853209717348'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1228162260000#c3993462853209717348' title=''/><author><name>Robert Nasiadek</name><uri>http://www.blogger.com/profile/06721470947386818024</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2130726592'/></entry><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-587485084362972468</id><published>2008-12-01T20:15:00.000+01:00</published><updated>2008-12-01T20:15:00.000+01:00</updated><title type='text'>Neither of these are good solutions.  The "ORDER B...</title><summary type='text'>Neither of these are good solutions.  The "ORDER BY RAND()" version is horribly inefficient, and the "find (rand Modelname.count)" version assumes that you have densely packed IDs from 1 to Modelname.count().  There's got to be a better way.</summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/587485084362972468'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/587485084362972468'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1228158900000#c587485084362972468' title=''/><author><name>bensonk</name><uri>http://bensonk.myopenid.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-601922712'/></entry><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-2906900387359046133</id><published>2007-12-14T22:22:00.000+01:00</published><updated>2007-12-14T22:22:00.000+01:00</updated><title type='text'>Some database servers probably optimize this kind ...</title><summary type='text'>Some database servers probably optimize this kind of stuff. MySQL just isn't one of them.&lt;BR/&gt;Here are some real numbers to get things clear. I've created table "numbers" and populated it with 100k rows. This query:&lt;BR/&gt;&lt;BR/&gt;select * from numbers order by rand() limit 1;&lt;BR/&gt;&lt;BR/&gt;takes 0.40s to complete. The other query:&lt;BR/&gt;&lt;BR/&gt;select * from numbers limit 12345,1;&lt;BR/&gt;&lt;BR/&gt;where 12345 is your </summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/2906900387359046133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/2906900387359046133'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1197667320000#c2906900387359046133' title=''/><author><name>robzon</name><uri>http://www.blogger.com/profile/06721470947386818024</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2130726592'/></entry><entry><id>tag:blogger.com,1999:blog-3069349063312276662.post-1276522158281227705</id><published>2007-12-14T21:31:00.000+01:00</published><updated>2007-12-14T21:31:00.000+01:00</updated><title type='text'>"performance killer"?&lt;br&gt;For sure it's not a good ...</title><summary type='text'>"performance killer"?&lt;BR/&gt;For sure it's not a good practice, but I'm wondering what is real life difference?&lt;BR/&gt;&lt;BR/&gt;Wouldn't query optimizator take care of it?</summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/1276522158281227705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3069349063312276662/8981556857198918385/comments/default/1276522158281227705'/><link rel='alternate' type='text/html' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html?showComment=1197664260000#c1276522158281227705' title=''/><author><name>marek</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://robzon.aenima.pl/2007/12/selecting-random-row-from-table.html' ref='tag:blogger.com,1999:blog-3069349063312276662.post-8981556857198918385' source='http://www.blogger.com/feeds/3069349063312276662/posts/default/8981556857198918385' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-907797834'/></entry></feed>
