Re: Analyze plan of foreign data wrapper - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Analyze plan of foreign data wrapper
Date
Msg-id 1530614287.2486.40.camel@cybertec.at
Whole thread Raw
In response to Re: Analyze plan of foreign data wrapper  (Mathieu PUJOL <mathieu.pujol@realfusio.com>)
Responses Re: Analyze plan of foreign data wrapper
List pgsql-general
Mathieu PUJOL wrote:
> I understand that I should also use varno to check which table is referenced by varattno. In case of Join,
aggregation,etc. Sometimes I get a number or INNER_VAR or OUTER_VAR.
 
> I am lost on how i could resolve this.
> I understand that OUTER_VAR/INNER_VAR are related to joins sub plans. Is outer related to left plan and inner to
rightplan ? In this case varattno is index of target list of subplan ?
 
> When varno is an index how to retrieve table info ?

I have no deep understanding of these things.

Maybe the following comment from include/nodes/primnodes.h can help:

/*
 * Var - expression node representing a variable (ie, a table column)
 *
 * Note: during parsing/planning, varnoold/varoattno are always just copies
 * of varno/varattno.  At the tail end of planning, Var nodes appearing in
 * upper-level plan nodes are reassigned to point to the outputs of their
 * subplans; for example, in a join node varno becomes INNER_VAR or OUTER_VAR
 * and varattno becomes the index of the proper element of that subplan's
 * target list.  Similarly, INDEX_VAR is used to identify Vars that reference
 * an index column rather than a heap column.  (In ForeignScan and CustomScan
 * plan nodes, INDEX_VAR is abused to signify references to columns of a
 * custom scan tuple type.)  In all these cases, varnoold/varoattno hold the
 * original values.  The code doesn't really need varnoold/varoattno, but they
 * are very useful for debugging and interpreting completed plans, so we keep
 * them around.
 */
#define    INNER_VAR        65000   /* reference to inner subplan */
#define    OUTER_VAR        65001   /* reference to outer subplan */
#define    INDEX_VAR        65002   /* reference to index column */

#define IS_SPECIAL_VARNO(varno)     ((varno) >= INNER_VAR)

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com


pgsql-general by date:

Previous
From: Valery Kuzmin
Date:
Subject: One transaction and several processes
Next
From: Łukasz Jarych
Date:
Subject: Using pg Admin to create backups and restore them