Bruno Wolff III <[EMAIL PROTECTED]> writes: > Enver ALTIN <[EMAIL PROTECTED]> wrote: >> I wish I could do something like: >> select tiptext from tips order by random limit 1 >> in PostgreSQL.
> You can but it won't be very efficient (for large tables) as it will generate > a random ordering for the whole table, probably do a sort and then return the > first record. The only thing different you need to do is add () after random: > select tiptext from tips order by random() limit 1 If you do need to do this for a large table, I seem to recall that we've previously worked out reasonable ways to select a random entry efficiently using an index. Dig around in the mail list archives for details. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match