Skip to content

Instantly share code, notes, and snippets.

@bitdivine
Created August 8, 2016 14:14
Show Gist options
  • Save bitdivine/409723a34a15bcd4cd0aa7d6816c7709 to your computer and use it in GitHub Desktop.
Save bitdivine/409723a34a15bcd4cd0aa7d6816c7709 to your computer and use it in GitHub Desktop.
Fast select random row from a Postgres table.
select * from MY_TABLE offset random()*(select count(*) from MY_TABLE) limit 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment