23 апреля 2012 г. 17:53 пользователь Kevin Grittner <kevin.gritt...@wicourts.gov> написал: > <suvisor.r...@gmail.com> wrote: > >> select * from testt where id = (random()* 100000)::integer; >> >> And sometimes it comes out something like this: >> id | val >> -------+-------- >> 11894 | 15051 >> 29233 | 42198 >> 80725 | 90213 >> 85688 | 100992 >> 88017 | 108075 >> (5 rows) >> Here can be 2, 3 or other rows amount in result... But must be >> only one! > > No, what you have written will scan the entire table and give each > row a 1 in 100000 chance of being selected. Maybe something like > this would give you what you want: > Hmm, is this because random() marked as volatile (and would be called for every row)? Ups, I not taken this into account... Sorry for bothering and thanks for reply!
-- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs