Last active
August 29, 2015 14:03
-
-
Save workmad3/5e8e74d1c6695f309ac0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Foo.transaction do | |
Foo.connection.execute("CREATE TEMPORARY TABLE temp_foos ON COMMIT DROP AS (SELECT *, RANDOM() AS rank FROM foos)") | |
Foo.select("temp_foos.*").from("temp_foos").order("rank").find_each do |foo| | |
#whatever | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment