| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера