Evaluate arguments of correlated SubPlans in the referencing ExprState - Mailing list pgsql-hackers

From Andres Freund
Subject Evaluate arguments of correlated SubPlans in the referencing ExprState
Date
Msg-id 20230225214401.346ancgjqc3zmvek@awork3.anarazel.de
Whole thread Raw
Responses Re: Evaluate arguments of correlated SubPlans in the referencing ExprState
List pgsql-hackers
Hi,

Around
https://www.postgresql.org/message-id/20230224015417.75yimxbksejpffh3%40awork3.anarazel.de
I suggested that we should evaluate the arguments of correlated SubPlans as
part of the expression referencing the subplan.

Here's a patch for that.

Ended up simpler than I'd thought. I see small, consistent, speedups and
reductions in memory usage.

I think individual arguments are mainly (always?)  Var nodes. By evaluating
them as part of the containing expression we avoid the increased memory usage,
and the increased dispatch of going through another layer of
ExprState. Because the arguments are a single Var, which end up with a
slot_getattr() via ExecJust*Var, we also elide redundant slot_getattr()
checks. I think we already avoided redundant tuple deforming, because the
parent ExprState will have done that already.

Greetings,

Andres Freund

Attachment

pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: use __builtin_clz to compute most significant bit set
Next
From: Nathan Bossart
Date:
Subject: Re: stopgap fix for signal handling during restore_command