Re: select into composite type / return
От | Gary Stainburn |
---|---|
Тема | Re: select into composite type / return |
Дата | |
Msg-id | e13395d5-10e5-3e83-1dd1-ad5d98d0e8b7@ringways.co.uk обсуждение исходный текст |
Ответ на | Re: select into composite type / return (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: select into composite type / return
|
Список | pgsql-sql |
On 18/03/2021 14:28, Tom Lane wrote: > Beware --- what that actually does is expand into > SELECT id, (do_breakdown(id)).f1, (do_breakdown(id)).f2, ... > > so that the function will be invoked N times if it produces N columns. > > What you generally want to do is invoke the function as a lateral FROM > item: > > SELECT id, f.* FROM table AS t, LATERAL do_breakdown(t.id) AS f; > > regards, tom lane Thanks for the info Tom, I can see how that would be quite a performance hit, not to mention adverse effects if these functions start doing updates. gary=# SELECT id, f.* FROM sessions AS t, LATERAL do_breakdown(t.id) AS f; id | f1 | f2 | f3 | f4 | f5 | f6 ----+-------+-------+-------+-------+-------+------- 1 | 1.00 | 2.00 | 3.00 | 4.00 | 5.00 | 6.00 2 | 11.00 | 12.00 | 13.00 | 14.00 | 15.00 | 16.00 3 | 21.00 | 22.00 | 23.00 | 24.00 | 25.00 | 26.00 (3 rows) gary=#
В списке pgsql-sql по дате отправления: