mirror of
https://github.com/postgres/postgres.git
synced 2025-09-05 02:22:28 +03:00
Include information on buffer usage during planning phase, in EXPLAIN output.
When BUFFERS option is enabled, EXPLAIN command includes the information on buffer usage during each plan node, in its output. In addition to that, this commit makes EXPLAIN command include also the information on buffer usage during planning phase, in its output. This feature makes it easier to discern the cases where lots of buffer access happen during planning. Author: Julien Rouhaud, slightly revised by Fujii Masao Reviewed-by: Justin Pryzby Discussion: https://postgr.es/m/16109-26a1a88651e90608@postgresql.org
This commit is contained in:
@@ -616,7 +616,11 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
|
||||
EState *estate = NULL;
|
||||
instr_time planstart;
|
||||
instr_time planduration;
|
||||
BufferUsage bufusage_start,
|
||||
bufusage;
|
||||
|
||||
if (es->buffers)
|
||||
bufusage_start = pgBufferUsage;
|
||||
INSTR_TIME_SET_CURRENT(planstart);
|
||||
|
||||
/* Look it up in the hash table */
|
||||
@@ -654,6 +658,13 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
|
||||
INSTR_TIME_SET_CURRENT(planduration);
|
||||
INSTR_TIME_SUBTRACT(planduration, planstart);
|
||||
|
||||
/* calc differences of buffer counters. */
|
||||
if (es->buffers)
|
||||
{
|
||||
memset(&bufusage, 0, sizeof(BufferUsage));
|
||||
BufferUsageAccumDiff(&bufusage, &pgBufferUsage, &bufusage_start);
|
||||
}
|
||||
|
||||
plan_list = cplan->stmt_list;
|
||||
|
||||
/* Explain each query */
|
||||
@@ -663,7 +674,7 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
|
||||
|
||||
if (pstmt->commandType != CMD_UTILITY)
|
||||
ExplainOnePlan(pstmt, into, es, query_string, paramLI, queryEnv,
|
||||
&planduration);
|
||||
&planduration, (es->buffers ? &bufusage : NULL));
|
||||
else
|
||||
ExplainOneUtility(pstmt->utilityStmt, into, es, query_string,
|
||||
paramLI, queryEnv);
|
||||
|
Reference in New Issue
Block a user