Re: BUG #6607: Strange select behavior

From: Александр Шепляков <suvisor(dot)root(at)gmail(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6607: Strange select behavior
Date: 2012-04-23 22:23:38
Message-ID: CALiGy8bJw3KkQVZrnBcGYOV=-9v2Fv9LBN=MS3WNAZxKwaXyrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

23 апреля 2012 г. 17:53 пользователь Kevin Grittner
<Kevin(dot)Grittner(at)wicourts(dot)gov> написал:
> <suvisor(dot)root(at)gmail(dot)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!

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2012-04-23 22:36:57 Re: BUG #6607: Strange select behavior
Previous Message biju.george 2012-04-23 15:16:40 BUG #6609: pattern matching (version 8.2 or so...)