LEFT JOIN LATERAL optimisation at plan time - Mailing list pgsql-performance

From Nicolas Paris
Subject LEFT JOIN LATERAL optimisation at plan time
Date
Msg-id 20180918070636.tp243ftlwpzrfrsd@riseup.net
Whole thread Raw
Responses Re: LEFT JOIN LATERAL optimisation at plan time
List pgsql-performance
Hi,

For a traditional LEFT JOIN, in case the SELECT does not mention a field
from a joined table being unique , the planner removes the join. Eg:

SELECT a, b --,c
FROM table1
LEFT JOIN (select a, c from table2 group by a) joined USING (a)

However this behavior is not the same for LATERAL JOINS

SELECT a, b --,c
FROM table1
LEFT JOIN LATERAL (select a, c from table2 where table1.a = table2.a group by a) joined ON TRUE

In this case, the planner still consider the joined table. My guess is
it could remove it .


Any thought ?

-- 
nicolas


pgsql-performance by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Select count(*) on a 2B Rows Tables Takes ~20 Hours
Next
From: Andrey Zhidenkov
Date:
Subject: Performance problems with Thai language