On 9/10/2025 10:52, Frits Jalvingh wrote:
> I do not understand why the simpler query (without the self join)
> produces a plan that seems to require nested loops, I hope someone can
> explain.
It seems obvious. You have a join clause:
'enheid.id_h_eenheid = huurovereenkomst_s._l_eenheid'
One side of this clause fits the underlying relation, but another one
does not (references the external relation).
According to the HashJoin rules, the hash join clause is quite strict:
each side should depend on only the left or right side of the join. So,
it is just impossible here.
What can be done here without rewriting the query? This subject requires
investigation to determine if the outer part of the hash clause can be
parameterised or not.
-- regards, Andrei Lepikhov
pgEdge