RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

THE BETTER WAY TO ORDER BY RAND in scope

ORDER by RAND() in MySQL is super slow. Jan Kneschke had wrote a article ORDER BY RAND() 3 years ago.This article explains a lot about his alternative ORDER BY RAND solution

But it’s find_by_sql version, I just refactor it to scope version THE BETTER WAY TO ORDER BY RAND in scope. And discuss more scenarios.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in