Re: About displaying NestLoopParam
Richard Guo <guofenglinux@gmail.com>
From: Richard Guo <guofenglinux@gmail.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2022-09-20T08:55:11Z
Lists: pgsql-hackers
Attachments
- v1-0001-Display-NestLoopParam-across-subplan.patch (application/octet-stream) patch v1-0001
On Fri, Sep 16, 2022 at 5:59 PM Richard Guo <guofenglinux@gmail.com> wrote: > I'm not saying this is a bug, but just curious why param 0 cannot be > displayed as the referenced expression. And I find the reason is that in > function find_param_referent(), we have the 'in_same_plan_level' flag > controlling that if we have emerged from a subplan, i.e. not the same > plan level any more, we would not look further for the matching > NestLoopParam. Param 0 suits this situation. > > And there is a comment there also saying, > > /* > * NestLoops transmit params to their inner child only; also, once > * we've crawled up out of a subplan, this couldn't possibly be > * the right match. > */ > After thinking of this for more time, I still don't see the reason why we cannot display NestLoopParam after we've emerged from a subplan. It seems these params are from parameterized subqueryscan and their values are supplied by an upper nestloop. These params should have been processed in process_subquery_nestloop_params() that we just add the PlannerParamItem entries to root->curOuterParams, in the form of NestLoopParam, using the same PARAM_EXEC slots. So I propose the patch attached to remove the 'in_same_plan_level' flag so that we can display NestLoopParam across subplan. Please correct me if I'm wrong. Thanks Richard
Commits
-
Improve ruleutils' printout of LATERAL references within subplans.
- adaf34241acd 16.0 landed
-
Teach EXPLAIN to print PARAM_EXEC Params as the referenced expressions,
- 1cc29fe7c60b 9.1.0 cited