Re: BUG #6607: Strange select behavior

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: ********* ******** <suvisor(dot)root(at)gmail(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6607: Strange select behavior
Date: 2012-04-23 22:36:57
Message-ID: 4F959339020000250004725A@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

********* ********<suvisor(dot)root(at)gmail(dot)com> wrote:
> Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov> *******:

>> what you have written will scan the entire table and give each
>> row a 1 in 100000 chance of being selected.
>>
> Hmm, is this because random() marked as volatile (and would be
> called for every row)? Ups, I not taken this into account...

The VOLATILE marker *guarantees* that random() will be run for every
row, but even with an immutable function you would be taking your
chances on how it might run, with the way it was coded. The
semantics are made unambiguous (I think) by making it a subquery in
the FROM clause.

-Kevin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Josh Kupershmidt 2012-04-23 23:51:34 Re: BUG #6609: pattern matching (version 8.2 or so...)
Previous Message Александр Шепляков 2012-04-23 22:23:38 Re: BUG #6607: Strange select behavior