pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Evaluate arguments of correlated SubPlans in the referencing Exp
Date: Thu, 01 Aug 2024 03:21:36 +0000
Message-ID: <E1sZMNk-00286R-8F@gemulon.postgresql.org> (raw)

Evaluate arguments of correlated SubPlans in the referencing ExprState

Until now we generated an ExprState for each parameter to a SubPlan and
evaluated them one-by-one ExecScanSubPlan. That's sub-optimal as creating lots
of small ExprStates
a) makes JIT compilation more expensive
b) wastes memory
c) is a bit slower to execute

This commit arranges to evaluate parameters to a SubPlan as part of the
ExprState referencing a SubPlan, using the new EEOP_PARAM_SET expression
step. We emit one EEOP_PARAM_SET for each argument to a subplan, just before
the EEOP_SUBPLAN step.

It likely is worth using EEOP_PARAM_SET in other places as well, e.g. for
SubPlan outputs, nestloop parameters and - more ambitiously - to get rid of
ExprContext->domainValue/caseValue/ecxt_agg*.  But that's for later.

Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Alena Rybakina <lena.ribackina@yandex.ru>
Discussion: https://postgr.es/m/20230225214401.346ancgjqc3zmvek@awork3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a7f107df2b700c859e4d9ad2ca66b07a465d6223

Modified Files
--------------
src/backend/executor/execExpr.c       | 103 +++++++++++++++++++++++-----------
src/backend/executor/execExprInterp.c |  26 +++++++++
src/backend/executor/execProcnode.c   |   5 ++
src/backend/executor/nodeSubplan.c    |  29 ++++------
src/backend/jit/llvm/llvmjit_expr.c   |   6 ++
src/backend/jit/llvm/llvmjit_types.c  |   1 +
src/include/executor/execExpr.h       |   6 +-
src/include/nodes/execnodes.h         |   1 -
8 files changed, 125 insertions(+), 52 deletions(-)



Message-ID: <E1sZMNk-00286R-8F@gemulon.postgresql.org>
Permalink:  ../E1sZMNk-00286R-8F@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sZMNk-00286R-8F@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Evaluate arguments of correlated SubPlans in the referencing Exp
  In-Reply-To: <E1sZMNk-00286R-8F@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox