-
-
Save codeactual/d037605d6ff42e465adcfbb6641921ac to your computer and use it in GitHub Desktop.
Efficient way to do random sampling in SQLite.
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
SELECT * FROM table | |
WHERE _ROWID_ >= (abs(random()) % (SELECT max(_ROWID_) FROM table)) | |
LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment