Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4a539a2

Browse files
committed
Expose BufferUsageAccumDiff().
Previously pg_stat_statements calculated the difference of buffer countersby its own code even while BufferUsageAccumDiff() had the same code.This commit expose BufferUsageAccumDiff() and makes pg_stat_statementsuse it for the calculation, in order to simply the code.This change also would be useful for the upcoming patch for the planningcounters in pg_stat_statements because the patch will add one more codefor the calculation of difference of buffer counters and that can easily bedone by using BufferUsageAccumDiff().Author: Julien RouhaudReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/bdfee4e0-a304-2498-8da5-3cb52c0a193e@oss.nttdata.com
1 parentb61d161 commit4a539a2

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,30 +1016,8 @@ pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
10161016
rows= (qc&&qc->commandTag==CMDTAG_COPY) ?qc->nprocessed :0;
10171017

10181018
/* calc differences of buffer counters. */
1019-
bufusage.shared_blks_hit=
1020-
pgBufferUsage.shared_blks_hit-bufusage_start.shared_blks_hit;
1021-
bufusage.shared_blks_read=
1022-
pgBufferUsage.shared_blks_read-bufusage_start.shared_blks_read;
1023-
bufusage.shared_blks_dirtied=
1024-
pgBufferUsage.shared_blks_dirtied-bufusage_start.shared_blks_dirtied;
1025-
bufusage.shared_blks_written=
1026-
pgBufferUsage.shared_blks_written-bufusage_start.shared_blks_written;
1027-
bufusage.local_blks_hit=
1028-
pgBufferUsage.local_blks_hit-bufusage_start.local_blks_hit;
1029-
bufusage.local_blks_read=
1030-
pgBufferUsage.local_blks_read-bufusage_start.local_blks_read;
1031-
bufusage.local_blks_dirtied=
1032-
pgBufferUsage.local_blks_dirtied-bufusage_start.local_blks_dirtied;
1033-
bufusage.local_blks_written=
1034-
pgBufferUsage.local_blks_written-bufusage_start.local_blks_written;
1035-
bufusage.temp_blks_read=
1036-
pgBufferUsage.temp_blks_read-bufusage_start.temp_blks_read;
1037-
bufusage.temp_blks_written=
1038-
pgBufferUsage.temp_blks_written-bufusage_start.temp_blks_written;
1039-
bufusage.blk_read_time=pgBufferUsage.blk_read_time;
1040-
INSTR_TIME_SUBTRACT(bufusage.blk_read_time,bufusage_start.blk_read_time);
1041-
bufusage.blk_write_time=pgBufferUsage.blk_write_time;
1042-
INSTR_TIME_SUBTRACT(bufusage.blk_write_time,bufusage_start.blk_write_time);
1019+
memset(&bufusage,0,sizeof(BufferUsage));
1020+
BufferUsageAccumDiff(&bufusage,&pgBufferUsage,&bufusage_start);
10431021

10441022
pgss_store(queryString,
10451023
0,/* signal that it's a utility stmt */

‎src/backend/executor/instrument.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ BufferUsage pgBufferUsage;
2121
staticBufferUsagesave_pgBufferUsage;
2222

2323
staticvoidBufferUsageAdd(BufferUsage*dst,constBufferUsage*add);
24-
staticvoidBufferUsageAccumDiff(BufferUsage*dst,
25-
constBufferUsage*add,constBufferUsage*sub);
2624

2725

2826
/* Allocate new instrumentation structure(s) */
@@ -203,7 +201,7 @@ BufferUsageAdd(BufferUsage *dst, const BufferUsage *add)
203201
}
204202

205203
/* dst += add - sub */
206-
staticvoid
204+
void
207205
BufferUsageAccumDiff(BufferUsage*dst,
208206
constBufferUsage*add,
209207
constBufferUsage*sub)

‎src/include/executor/instrument.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ extern void InstrAggNode(Instrumentation *dst, Instrumentation *add);
8181
externvoidInstrStartParallelQuery(void);
8282
externvoidInstrEndParallelQuery(BufferUsage*result);
8383
externvoidInstrAccumParallelQuery(BufferUsage*result);
84+
externvoidBufferUsageAccumDiff(BufferUsage*dst,
85+
constBufferUsage*add,constBufferUsage*sub);
8486

8587
#endif/* INSTRUMENT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp