Re: [HACKERS] CTE inlining
От | David G. Johnston |
---|---|
Тема | Re: [HACKERS] CTE inlining |
Дата | |
Msg-id | CAKFQuwawh+p0-XR6_wcOuHsi7ppk7_=q8ZRLsD4qbd0NDxyGwQ@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [HACKERS] CTE inlining (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>) |
Ответы |
Re: [HACKERS] CTE inlining
Re: [HACKERS] CTE inlining |
Список | pgsql-hackers |
Yeah, the idea that this won't cause possibly significant pain is quite wrong. Quite by accident I came across an example just this morning where rewriting as a CTE makes a big improvement.
I wrote this query:
select (json_populate_record(null::mytype, myjson)).*
from mytable;
It turned out that this was an order of magnitude faster:
with r as
(
select json_populate_record(null::mytype, myjson) as x
from mytable
)
select (x).*
from r;
Except I suspect we at least have a chance to detect the above and not de-optimize it by evaluating "json_populate_record" once for every column in mytype.
The now idiomatic solution to the above is to use LATERAL so the above CTE is no longer actually a required workaround.
David J.
В списке pgsql-hackers по дате отправления: