How can I select random rows in PostgreSQL?

1149215 pts.
Tags:
Database
PostgreSQL
I'm looking to get a random selection of rows from PostgreSQL. I've already tried this:
select * from table where random() < 0.01;
But one of my friends told me to use this:
select * from table order by random() limit 1000;
My table has over 200 million rows so I need it to be fast. Which way should I use? Thank you.
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: