I have a table on a PostgreSQL server database with almost 3 million rows and I need to save all rows to a CSV file. The problem here is that the rows must
See this question Selecting random rows
See this wonderful link Depesz MY THOUGHTS ON GETTING RANDOM ROW
Typically, you can just ORDER BY
a random function of your database flavor, like
SELECT * FROM table ORDER BY RANDOM()
This might be as slow as shuffling the list, depending on the database server or product.