Re: random generated string matching index in inexplicable ways

2019-05-07 Thread Francisco Olarte
On Tue, May 7, 2019 at 3:12 PM Myles Miller wrote: > No, the function is returning just one letter, either 'A' or 'B', not > multiple values. Your random function is being evaluated ONCE FOR EACH ROW. i.e, it's doing something like: select y from ( SELECT y, chr(round(random())::int + 65) as

Re: random generated string matching index in inexplicable ways

2019-05-07 Thread Myles Miller
> > # SELECT y FROM x WHERE y = chr(round(random())::int + 65); > > y > > --- > > A > > B > > (2 rows) > Here you got a random value in the lower range of 0..1 for the record with > value ‘A’, so that’s a match, and one in the higher range for value ‘B’, a > match again, so you get 2 rows. No,

Re: random generated string matching index in inexplicable ways [EXT]

2019-05-07 Thread Myles Miller
On Tue, May 07, 2019 at 12:17:12PM +, Daniel Perrett wrote: > The WHERE expression (and therefore the random function) is being evaluated > once per row, not once per query. > If you run this query a few times, you will see the problem: > SELECT y, chr(round(random())::int + 65) FROM (SELECT '

Re: random generated string matching index in inexplicable ways

2019-05-07 Thread Alban Hertroys
> On 7 May 2019, at 13:53, Myles Miller wrote: > > PROBLEM: > Strings or characters generated by any random function (including pg_crypto > gen_random_bytes) are matching a string/char index in surprising ways. I fail to see anything surprising in your examples. > Reduced down to its simplest