LEFT JOIN LATERAL optimisation at plan time

From: Nicolas Paris <nicolas(dot)paris(at)riseup(dot)net>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: LEFT JOIN LATERAL optimisation at plan time
Date: 2018-09-18 07:06:36
Message-ID: 20180918070636.tp243ftlwpzrfrsd@riseup.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andrey Zhidenkov 2018-09-18 07:31:08 Performance problems with Thai language
Previous Message Stephen Frost 2018-09-17 19:34:20 Re: Big image tables maintenance