Could the random() be made part of an expression (that doesn't change the result) to fool the optimizer into only doing the random() once, like this:
SELECT ( random() * col_thats_always_one ) AS x FROM table ORDER BY x Jeff > On Aug 17, 2015, at 5:01 AM, Clemens Ladisch <clemens at ladisch.de> wrote: > > select random() as x from some_non_empty_table order by x desc limit 20;