Posted on 10th September 2024|59 views
Explain Order by Random() in PostgfreSQL?
Posted on 10th September 2024| views
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