mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Add memory/disk usage for Material nodes in EXPLAIN
Up until now, there was no ability to easily determine if a Material node caused the underlying tuplestore to spill to disk or even see how much memory the tuplestore used if it didn't. Here we add some new functions to tuplestore.c to query this information and add some additional output in EXPLAIN ANALYZE to display this information for the Material node. There are a few other executor node types that use tuplestores, so we could also consider adding these details to the EXPLAIN ANALYZE for those nodes too. Let's consider those independently from this. Having the tuplestore.c infrastructure in to allow that is step 1. Author: David Rowley Reviewed-by: Matthias van de Meent, Dmitry Dolgov Discussion: https://postgr.es/m/CAApHDvp5Py9g4Rjq7_inL3-MCK1Co2CRt_YWFwTU2zfQix0p4A@mail.gmail.com
This commit is contained in:
@ -125,6 +125,7 @@ static void show_sort_info(SortState *sortstate, ExplainState *es);
|
||||
static void show_incremental_sort_info(IncrementalSortState *incrsortstate,
|
||||
ExplainState *es);
|
||||
static void show_hash_info(HashState *hashstate, ExplainState *es);
|
||||
static void show_material_info(MaterialState *mstate, ExplainState *es);
|
||||
static void show_memoize_info(MemoizeState *mstate, List *ancestors,
|
||||
ExplainState *es);
|
||||
static void show_hashagg_info(AggState *aggstate, ExplainState *es);
|
||||
@ -2251,6 +2252,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
case T_Hash:
|
||||
show_hash_info(castNode(HashState, planstate), es);
|
||||
break;
|
||||
case T_Material:
|
||||
show_material_info(castNode(MaterialState, planstate), es);
|
||||
break;
|
||||
case T_Memoize:
|
||||
show_memoize_info(castNode(MemoizeState, planstate), ancestors,
|
||||
es);
|
||||
@ -3322,6 +3326,39 @@ show_hash_info(HashState *hashstate, ExplainState *es)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show information on material node, storage method and maximum memory/disk
|
||||
* space used.
|
||||
*/
|
||||
static void
|
||||
show_material_info(MaterialState *mstate, ExplainState *es)
|
||||
{
|
||||
Tuplestorestate *tupstore;
|
||||
const char *storageType;
|
||||
int64 spaceUsedKB;
|
||||
|
||||
if (!es->analyze)
|
||||
return;
|
||||
|
||||
tupstore = mstate->tuplestorestate;
|
||||
storageType = tuplestore_storage_type_name(tupstore);
|
||||
spaceUsedKB = BYTES_TO_KILOBYTES(tuplestore_space_used(tupstore));
|
||||
|
||||
if (es->format != EXPLAIN_FORMAT_TEXT)
|
||||
{
|
||||
ExplainPropertyText("Storage", storageType, es);
|
||||
ExplainPropertyInteger("Maximum Storage", "kB", spaceUsedKB, es);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplainIndentText(es);
|
||||
appendStringInfo(es->str,
|
||||
"Storage: %s Maximum Storage: " INT64_FORMAT "kB\n",
|
||||
storageType,
|
||||
spaceUsedKB);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Show information on memoize hits/misses/evictions and memory usage.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user