One possible way to select random rows in PostgreSQL is this:
select * from table order by random() limit 1000;
(see also here.)
My question is, what does order by random() mean exactly? Is it that somehow a random number is generated and it is taken as some kind of "seed"? Or is this special built in syntax, and in this place random() has a different meaning than in other contexts?
From some experimentation, the last explanation seems more plausible. Consider the following:
# select random();
random
═══════════════════
0.336829286068678
(1 row)
# select * from article order by 0.336829286068678 limit 5;
ERROR: non-integer constant in ORDER BY
LINE 1: select * from article order by 0.336829286068678 limit 5;