Re: Optimization of NestLoop join in the case of guaranteed empty inner subtree - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Optimization of NestLoop join in the case of guaranteed empty inner subtree
Date
Msg-id 15239.1576079353@sss.pgh.pa.us
Whole thread Raw
In response to Optimization of NestLoop join in the case of guaranteed empty innersubtree  (Andrey Lepikhov <a.lepikhov@postgrespro.ru>)
Responses Re: Optimization of NestLoop join in the case of guaranteed emptyinner subtree  (Andrey Lepikhov <a.lepikhov@postgrespro.ru>)
List pgsql-hackers
Andrey Lepikhov <a.lepikhov@postgrespro.ru> writes:
> 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.

So the first question about corner-case optimizations like this is always
"how much overhead does it add in the normal case where it fails to gain
anything?".  I see no performance numbers in your proposal.

I do not much like anything about the code, either: as written it's
only helpful for an especially narrow corner case (so narrow that
I wonder if it really ever helps at all: surely calling a nodeMaterial
whose tuplestore is empty doesn't cost much).  But that doesn't stop it
from adding a bool to the generic PlanState struct, with global
implications.  What I'd expected from your text description is that
nodeNestLoop would remember whether its inner child had returned zero rows
the first time, and assume that subsequent executions could be skipped
unless the inner child's parameters change.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: adding partitioned tables to publications
Next
From: Robert Haas
Date:
Subject: Re: allowing broader use of simplehash