Posted on 25th April 2024
Order by random() used for testing purposes where you need random data then we go with this Order by random() functionality.
PostgreSQL fetches all the columns from the mentioned table and then selects a random row. Therefore, this is quite helpful and fast for small tables but large tables like tables having 750 million columns. It takes a few minutes, which is a drawback for this functionality.
Syntax:
SELECT column FROM table
ORDER BY RANDOM ()
LIMIT 1
STILL GOT QUERIES?