Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rowley2024-09-12 04:02:01 +0000
committerDavid Rowley2024-09-12 04:02:01 +0000
commit9fba1ed2947382af213dfbfabfcd8898c89bf4ca (patch)
tree48636fbcd68879eb38b5e330e715e820c4936d7e /src/backend/commands/explain.c
parente6c45d85dc168fb05b5ee5596a4de5167c9fe01f (diff)
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
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 14cd36c87c5..2819e479f82 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -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);
}
}