mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Adjust tuplestore stats API
1eff8279d
added an API to tuplestore.c to allow callers to obtain
storage telemetry data. That API wasn't quite good enough for callers
that perform tuplestore_clear() as the telemetry functions only
accounted for the current state of the tuplestore, not the maximums
before tuplestore_clear() was called.
There's a pending patch that would like to add tuplestore telemetry
output to EXPLAIN ANALYZE for WindowAgg. That node type uses
tuplestore_clear() before moving to the next window partition and we
want to show the maximum space used, not the space used for the final
partition.
Reviewed-by: Tatsuo Ishii, Ashutosh Bapat
Discussion: https://postgres/m/CAApHDvoY8cibGcicLV0fNh=9JVx9PANcWvhkdjBnDCc9Quqytg@mail.gmail.com
This commit is contained in:
@ -3350,8 +3350,9 @@ static void
|
||||
show_material_info(MaterialState *mstate, ExplainState *es)
|
||||
{
|
||||
Tuplestorestate *tupstore = mstate->tuplestorestate;
|
||||
const char *storageType;
|
||||
int64 spaceUsedKB;
|
||||
char *maxStorageType;
|
||||
int64 maxSpaceUsed,
|
||||
maxSpaceUsedKB;
|
||||
|
||||
/*
|
||||
* Nothing to show if ANALYZE option wasn't used or if execution didn't
|
||||
@ -3360,21 +3361,21 @@ show_material_info(MaterialState *mstate, ExplainState *es)
|
||||
if (!es->analyze || tupstore == NULL)
|
||||
return;
|
||||
|
||||
storageType = tuplestore_storage_type_name(tupstore);
|
||||
spaceUsedKB = BYTES_TO_KILOBYTES(tuplestore_space_used(tupstore));
|
||||
tuplestore_get_stats(tupstore, &maxStorageType, &maxSpaceUsed);
|
||||
maxSpaceUsedKB = BYTES_TO_KILOBYTES(maxSpaceUsed);
|
||||
|
||||
if (es->format != EXPLAIN_FORMAT_TEXT)
|
||||
{
|
||||
ExplainPropertyText("Storage", storageType, es);
|
||||
ExplainPropertyInteger("Maximum Storage", "kB", spaceUsedKB, es);
|
||||
ExplainPropertyText("Storage", maxStorageType, es);
|
||||
ExplainPropertyInteger("Maximum Storage", "kB", maxSpaceUsedKB, es);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplainIndentText(es);
|
||||
appendStringInfo(es->str,
|
||||
"Storage: %s Maximum Storage: " INT64_FORMAT "kB\n",
|
||||
storageType,
|
||||
spaceUsedKB);
|
||||
maxStorageType,
|
||||
maxSpaceUsedKB);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user