This is the plan I get:
Limit (cost=56.39..56.41 rows=10 width=40)
-> Sort (cost=56.39..59.79 rows=1360 width=40)
Sort Key: (random())
-> Seq Scan on test (cost=0.00..27.00 rows=1360 width=40)
One should use "FROM table TABLESAMPLE SYSTEM (size)", this is the plan: Sample Scan on test (cost=0.00..5.36 rows=136 width=32)
Sampling: system ('10'::real)
You can also use different distribution method than "SYSTEM", and you can make it reproducible with a seed.https://www.postgresql.org/docs/current/sql-select.html#SQL-...
ORDER BY random() is a really un-optimized bad practice to get a random sample on PostgreSQL. If you use another SQL database, the best thing to do is to use UUIDv4 as primary key, and use "ORDER BY pk LIMIT size".