mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Improve EXPLAIN's display of SubPlan nodes and output parameters.
Historically we've printed SubPlan expression nodes as "(SubPlan N)", which is pretty uninformative. Trying to reproduce the original SQL for the subquery is still as impractical as before, and would be mighty verbose as well. However, we can still do better than that. Displaying the "testexpr" when present, and adding a keyword to indicate the SubLinkType, goes a long way toward showing what's really going on. In addition, this patch gets rid of EXPLAIN's use of "$n" to represent subplan and initplan output Params. Instead we now print "(SubPlan N).colX" or "(InitPlan N).colX" to represent the X'th output column of that subplan. This eliminates confusion with the use of "$n" to represent PARAM_EXTERN Params, and it's useful for the first part of this change because it eliminates needing some other indication of which subplan is referenced by a SubPlan that has a testexpr. In passing, this adds simple regression test coverage of the ROWCOMPARE_SUBLINK code paths, which were entirely unburdened by testing before. Tom Lane and Dean Rasheed, reviewed by Aleksander Alekseev. Thanks to Chantal Keller for raising the question of whether this area couldn't be improved. Discussion: https://postgr.es/m/2838538.1705692747@sss.pgh.pa.us
This commit is contained in:
@ -116,7 +116,6 @@ static void show_tidbitmap_info(BitmapHeapScanState *planstate,
|
||||
static void show_instrumentation_count(const char *qlabel, int which,
|
||||
PlanState *planstate, ExplainState *es);
|
||||
static void show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es);
|
||||
static void show_eval_params(Bitmapset *bms_params, ExplainState *es);
|
||||
static const char *explain_get_index_name(Oid indexId);
|
||||
static bool peek_buffer_usage(ExplainState *es, const BufferUsage *usage);
|
||||
static void show_buffer_usage(ExplainState *es, const BufferUsage *usage);
|
||||
@ -1914,10 +1913,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
ExplainPropertyInteger("Workers Planned", NULL,
|
||||
gather->num_workers, es);
|
||||
|
||||
/* Show params evaluated at gather node */
|
||||
if (gather->initParam)
|
||||
show_eval_params(gather->initParam, es);
|
||||
|
||||
if (es->analyze)
|
||||
{
|
||||
int nworkers;
|
||||
@ -1942,10 +1937,6 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
ExplainPropertyInteger("Workers Planned", NULL,
|
||||
gm->num_workers, es);
|
||||
|
||||
/* Show params evaluated at gather-merge node */
|
||||
if (gm->initParam)
|
||||
show_eval_params(gm->initParam, es);
|
||||
|
||||
if (es->analyze)
|
||||
{
|
||||
int nworkers;
|
||||
@ -3550,29 +3541,6 @@ show_foreignscan_info(ForeignScanState *fsstate, ExplainState *es)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show initplan params evaluated at Gather or Gather Merge node.
|
||||
*/
|
||||
static void
|
||||
show_eval_params(Bitmapset *bms_params, ExplainState *es)
|
||||
{
|
||||
int paramid = -1;
|
||||
List *params = NIL;
|
||||
|
||||
Assert(bms_params);
|
||||
|
||||
while ((paramid = bms_next_member(bms_params, paramid)) >= 0)
|
||||
{
|
||||
char param[32];
|
||||
|
||||
snprintf(param, sizeof(param), "$%d", paramid);
|
||||
params = lappend(params, pstrdup(param));
|
||||
}
|
||||
|
||||
if (params)
|
||||
ExplainPropertyList("Params Evaluated", params, es);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch the name of an index in an EXPLAIN
|
||||
*
|
||||
|
Reference in New Issue
Block a user