The problem with this is that order by RAND is extremely inefficient
as it has to evaluate RAND() for every row in the table. I'm hesitant
to stick something this ... dangerous into the core framework itself.
--
Cheers
Koz
>
> One of the comments in my blog suggested a way to improve the
> performance in mysql (http://jan.kneschke.de/projects/mysql/order-by-
> rand/).
>
> I guess that there are other tweaks for other database systems (like
> db2, oracle, postgre, sqlite). So in the core we could have the
> tweaked fast versions of random for each of the dbms. Then the user
> would only need to
>
>>> Quote.find(:random)
>
> And rails would do the magic :)
I read Jan's entry as well a while ago, and it's very interesting.
However, it's also pretty laborious and not trivial to implement
across different databases. So I feel this is a good candidate for a
plugin but certainly not for core, at least at this point.
Cheers,
//jarkko
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
Another thought on random ordering: I'd like to see how this is
testable without sticking to mocks :)
--
MK