`order by random()` makes select-list `random()` invocations deterministic

Поиск
Список
Период
Сортировка
От Dian Fay
Тема `order by random()` makes select-list `random()` invocations deterministic
Дата
Msg-id CZHAF947QQQO.27MAUK2SVMBXW@nmfay.com
обсуждение исходный текст
Ответы Re: `order by random()` makes select-list `random()` invocations deterministic  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-bugs
In Postgres 16.1, running the following query:

```
select
  gs,
  gs + random() * 100 - 50 as gs2,
  random() * 100 - 50 as r1,
  random() * 100 - 50 as r2,
  random() * 100 - 50 as r3
from generate_series(0, 10) as gs
order by random();
```

Every `random()` invocation in the select list uses a single consistent
value within each returned row. Remove the `order by random()` and
values become randomized as expected, but it gets a bit stranger:

- order by any of the `rN` values and `gs2` uses a different random
  value, but all the `rN` values are identical;
- order by `gs2` and all random values are distinct again.



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Andrei Lepikhov
Дата:
Сообщение: Re: BUG #18349: ERROR: invalid DSA memory alloc request size 1811939328, CONTEXT: parallel worker
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: Feature bug dumpall CREATE ROLE postgres