Evaluate arguments of correlated SubPlans in the referencing ExprState

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Evaluate arguments of correlated SubPlans in the referencing ExprState
Date: 2023-02-25 21:44:01
Message-ID: 20230225214401.346ancgjqc3zmvek@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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.


Andres Freund

Attachment Content-Type Size
v1-0001-WIP-Evaluate-arguments-of-correlated-SubPlans-in-.patch text/x-diff 8.7 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2023-02-25 22:06:29 Re: stopgap fix for signal handling during restore_command
Previous Message Magnus Hagander 2023-02-25 20:47:16 Re: use __builtin_clz to compute most significant bit set