Re: [HACKERS] incomplete removal of not referenced CTEs

2016-09-01 Thread Tomas Vondra
On 09/01/2016 09:58 PM, Andres Freund wrote: > On 2016-09-01 15:46:45 -0400, Tom Lane wrote: >> Tomas Vondra writes: >>> While investigating a CTE-related query, I've noticed that we don't >>> really remove all unreachable CTEs. >> >> We expend a grand total of

Re: [HACKERS] incomplete removal of not referenced CTEs

2016-09-01 Thread Andres Freund
On 2016-09-01 15:46:45 -0400, Tom Lane wrote: > Tomas Vondra writes: > > While investigating a CTE-related query, I've noticed that we don't > > really remove all unreachable CTEs. > > We expend a grand total of three lines of code on making that happen. > I'm

Re: [HACKERS] incomplete removal of not referenced CTEs

2016-09-01 Thread Tom Lane
Tomas Vondra writes: > While investigating a CTE-related query, I've noticed that we don't > really remove all unreachable CTEs. We expend a grand total of three lines of code on making that happen. I'm pretty much -1 on adding a great deal more code or complexity

Re: [HACKERS] incomplete removal of not referenced CTEs

2016-09-01 Thread Andres Freund
On 2016-09-01 21:36:13 +0200, Tomas Vondra wrote: > Of course, it's harmless as none of those CTEs gets actually executed, > but is this intentional, or do we want/need to fix it? I don't see > anything about this in the docs, but it seems a bit awkward and > confusing to remove only some of the

[HACKERS] incomplete removal of not referenced CTEs

2016-09-01 Thread Tomas Vondra
Hi, While investigating a CTE-related query, I've noticed that we don't really remove all unreachable CTEs. For example, for this query with a as (select 1), b as (select * from a), c as (select * from b) select 2; where none of the CTEs if (directly or indirectly)