Joined May 2011
·

Matt Polito

Software Engineer at Hashrocket
·
Ponte Vedra, FL
·
·
·

Posted to Rails Quick Tips - Random Records over 1 year ago

Thanks @spilliton for going through your thought process on this. I'd have loved to see those benchmarks.

As already stated, Hub is a really great library for this kind of thing.

Posted to Rails Quick Tips - Random Records over 1 year ago

@natebird Thanks for pointing out randumb. I've seen this in the past but never used it. It is DB agnostic as much as my described implementation is. The gem is only using either of two database functions ('RANDOM() and RAND()'). You always need to evaluate your options when it comes to your specific scenario... in regards to high record count and performance.

Thanks again for checking out the article!

Posted to Rails Quick Tips - Random Records over 1 year ago

@narkoz I just threw together the examples that would be worse than the end implementation. You are correct though, sample would have been a better choice to implement that way.

Thanks!

Achievements
215 Karma
14,353 Total ProTip Views