Optimization of NestLoop join in the case of guaranteed empty innersubtree - Mailing list pgsql-hackers

From Andrey Lepikhov
Subject Optimization of NestLoop join in the case of guaranteed empty innersubtree
Date
Msg-id a373827a-260c-2b05-e7e6-32f4135ec093@postgrespro.ru
Whole thread Raw
Responses Re: Optimization of NestLoop join in the case of guaranteed empty inner subtree  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
During NestLoop execution we have bad corner case: if outer subtree 
contains tuples the join node will scan inner subtree even if it does 
not return any tuples.

To reproduce the problem see 'problem.sql' in attachment:
Out of explain analyze see in 'problem_explain.txt'

As you can see, executor scan each of 1e5 outer tuples despite the fact 
that inner can't return any tuples.

Teodor Sigaev and I developed a patch to solve this problem. Result of 
explain analyze procedure can be found in the 'optimized_execution.txt'.

-- 
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company

Attachment

pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: RE: [Proposal] Level4 Warnings show many shadow vars
Next
From: Julien Rouhaud
Date:
Subject: Re: Collation versioning