Re: BUG #6607: Strange select behavior - Mailing list pgsql-bugs

From Александр Шепляков
Subject Re: BUG #6607: Strange select behavior
Date
Msg-id CALiGy8bJw3KkQVZrnBcGYOV=-9v2Fv9LBN=MS3WNAZxKwaXyrw@mail.gmail.com
Whole thread Raw
In response to Re: BUG #6607: Strange select behavior  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-bugs
23 апреля 2012 г. 17:53 пользователь Kevin Grittner
<Kevin.Grittner@wicourts.gov> написал:
> <suvisor.root@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!


pgsql-bugs by date:

Previous
From: biju.george@ust-global.com
Date:
Subject: BUG #6609: pattern matching (version 8.2 or so...)
Next
From: Josh Kupershmidt
Date:
Subject: Re: BUG #6609: pattern matching (version 8.2 or so...)