Re: Reference to parent query from ANY sublink

From: Antonin Houska <antonin(dot)houska(at)gmail(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reference to parent query from ANY sublink
Date: 2013-10-31 20:37:14
Message-ID: 5272BF7A.2000206@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/31/2013 03:46 PM, Antonin Houska wrote:
> Can the change be as simple as this or do I neglect anything?

Well, the example of outer join is wrong. Instead I think query

SELECT *
FROM tab1 a
LEFT JOIN
tab1 b
ON b.i = ANY (
SELECT tab2.k
FROM tab2
WHERE k = a.j);

should be converted to

SELECT *
FROM tab1 a
LEFT JOIN
( tab1 b
LATERAL SEMI JOIN
( SELECT tab2.k
FROM tab2
WHERE k = a.j
) AS ANY_subquery
ON b.i = sub.k
)

I'm not sure if it's legal for the WHERE clause to reference LHS of the
original outer join (a.j). Some more restriction may be needed. I need
to think about it a bit more.

// Tony

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2013-10-31 22:22:57 Re: [BUGS] BUG #8542: Materialized View with another column_name does not work?
Previous Message Kevin Grittner 2013-10-31 19:57:47 Re: Feature request: Optimizer improvement