Re: Random function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Random function
Дата
Msg-id 23973.1585074791@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Random function  (Luis Roberto Weck <luisroberto@siscobra.com.br>)
Список pgsql-performance
Luis Roberto Weck <luisroberto@siscobra.com.br> writes:
> I am trying to generate some random data using the random() function.

> However, I am getting the same result over mulitiple rows. This is a 
> sample of the SQL I am using:

> select (select string_agg(random()::text,';')
>         from pg_catalog.generate_series(1,3,1) )
>   from generate_series(1,10,1)

The sub-select is independent of the outer select so it's only computed
once, and then you get ten copies of that result.  Restructuring the
query, or inserting an artificial dependency on the outer select's data,
would help.

            regards, tom lane



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

Предыдущее
От: Luis Roberto Weck
Дата:
Сообщение: Random function
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Random function