Commit 1dd89ead authored by Tom Lane's avatar Tom Lane

Rename I/O timing statistics columns to blk_read_time and blk_write_time.

This seems more consistent with the pre-existing choices for names of
other statistics columns.  Rename assorted internal identifiers to match.
parent 309c6474
...@@ -29,8 +29,8 @@ CREATE FUNCTION pg_stat_statements( ...@@ -29,8 +29,8 @@ CREATE FUNCTION pg_stat_statements(
OUT local_blks_written int8, OUT local_blks_written int8,
OUT temp_blks_read int8, OUT temp_blks_read int8,
OUT temp_blks_written int8, OUT temp_blks_written int8,
OUT time_read float8, OUT blk_read_time float8,
OUT time_write float8 OUT blk_write_time float8
) )
RETURNS SETOF record RETURNS SETOF record
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
......
...@@ -26,8 +26,8 @@ CREATE FUNCTION pg_stat_statements( ...@@ -26,8 +26,8 @@ CREATE FUNCTION pg_stat_statements(
OUT local_blks_written int8, OUT local_blks_written int8,
OUT temp_blks_read int8, OUT temp_blks_read int8,
OUT temp_blks_written int8, OUT temp_blks_written int8,
OUT time_read float8, OUT blk_read_time float8,
OUT time_write float8 OUT blk_write_time float8
) )
RETURNS SETOF record RETURNS SETOF record
AS 'MODULE_PATHNAME' AS 'MODULE_PATHNAME'
......
...@@ -103,19 +103,19 @@ typedef struct Counters ...@@ -103,19 +103,19 @@ typedef struct Counters
int64 calls; /* # of times executed */ int64 calls; /* # of times executed */
double total_time; /* total execution time, in msec */ double total_time; /* total execution time, in msec */
int64 rows; /* total # of retrieved or affected rows */ int64 rows; /* total # of retrieved or affected rows */
int64 shared_blks_hit; /* # of shared buffer hits */ int64 shared_blks_hit; /* # of shared buffer hits */
int64 shared_blks_read; /* # of shared disk blocks read */ int64 shared_blks_read; /* # of shared disk blocks read */
int64 shared_blks_dirtied; /* # of shared disk blocks dirtied */ int64 shared_blks_dirtied; /* # of shared disk blocks dirtied */
int64 shared_blks_written; /* # of shared disk blocks written */ int64 shared_blks_written; /* # of shared disk blocks written */
int64 local_blks_hit; /* # of local buffer hits */ int64 local_blks_hit; /* # of local buffer hits */
int64 local_blks_read; /* # of local disk blocks read */ int64 local_blks_read; /* # of local disk blocks read */
int64 local_blks_dirtied; /* # of local disk blocks dirtied */ int64 local_blks_dirtied; /* # of local disk blocks dirtied */
int64 local_blks_written; /* # of local disk blocks written */ int64 local_blks_written; /* # of local disk blocks written */
int64 temp_blks_read; /* # of temp blocks read */ int64 temp_blks_read; /* # of temp blocks read */
int64 temp_blks_written; /* # of temp blocks written */ int64 temp_blks_written; /* # of temp blocks written */
double time_read; /* time spent reading, in msec */ double blk_read_time; /* time spent reading, in msec */
double time_write; /* time spent writing, in msec */ double blk_write_time; /* time spent writing, in msec */
double usage; /* usage factor */ double usage; /* usage factor */
} Counters; } Counters;
/* /*
...@@ -846,10 +846,10 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString, ...@@ -846,10 +846,10 @@ pgss_ProcessUtility(Node *parsetree, const char *queryString,
pgBufferUsage.temp_blks_read - bufusage_start.temp_blks_read; pgBufferUsage.temp_blks_read - bufusage_start.temp_blks_read;
bufusage.temp_blks_written = bufusage.temp_blks_written =
pgBufferUsage.temp_blks_written - bufusage_start.temp_blks_written; pgBufferUsage.temp_blks_written - bufusage_start.temp_blks_written;
bufusage.time_read = pgBufferUsage.time_read; bufusage.blk_read_time = pgBufferUsage.blk_read_time;
INSTR_TIME_SUBTRACT(bufusage.time_read, bufusage_start.time_read); INSTR_TIME_SUBTRACT(bufusage.blk_read_time, bufusage_start.blk_read_time);
bufusage.time_write = pgBufferUsage.time_write; bufusage.blk_write_time = pgBufferUsage.blk_write_time;
INSTR_TIME_SUBTRACT(bufusage.time_write, bufusage_start.time_write); INSTR_TIME_SUBTRACT(bufusage.blk_write_time, bufusage_start.blk_write_time);
/* For utility statements, we just hash the query string directly */ /* For utility statements, we just hash the query string directly */
queryId = pgss_hash_string(queryString); queryId = pgss_hash_string(queryString);
...@@ -1021,8 +1021,8 @@ pgss_store(const char *query, uint32 queryId, ...@@ -1021,8 +1021,8 @@ pgss_store(const char *query, uint32 queryId,
e->counters.local_blks_written += bufusage->local_blks_written; e->counters.local_blks_written += bufusage->local_blks_written;
e->counters.temp_blks_read += bufusage->temp_blks_read; e->counters.temp_blks_read += bufusage->temp_blks_read;
e->counters.temp_blks_written += bufusage->temp_blks_written; e->counters.temp_blks_written += bufusage->temp_blks_written;
e->counters.time_read += INSTR_TIME_GET_MILLISEC(bufusage->time_read); e->counters.blk_read_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_read_time);
e->counters.time_write += INSTR_TIME_GET_MILLISEC(bufusage->time_write); e->counters.blk_write_time += INSTR_TIME_GET_MILLISEC(bufusage->blk_write_time);
e->counters.usage += USAGE_EXEC(total_time); e->counters.usage += USAGE_EXEC(total_time);
SpinLockRelease(&e->mutex); SpinLockRelease(&e->mutex);
...@@ -1163,8 +1163,8 @@ pg_stat_statements(PG_FUNCTION_ARGS) ...@@ -1163,8 +1163,8 @@ pg_stat_statements(PG_FUNCTION_ARGS)
values[i++] = Int64GetDatumFast(tmp.temp_blks_written); values[i++] = Int64GetDatumFast(tmp.temp_blks_written);
if (sql_supports_v1_1_counters) if (sql_supports_v1_1_counters)
{ {
values[i++] = Float8GetDatumFast(tmp.time_read); values[i++] = Float8GetDatumFast(tmp.blk_read_time);
values[i++] = Float8GetDatumFast(tmp.time_write); values[i++] = Float8GetDatumFast(tmp.blk_write_time);
} }
Assert(i == (sql_supports_v1_1_counters ? Assert(i == (sql_supports_v1_1_counters ?
......
...@@ -839,13 +839,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re ...@@ -839,13 +839,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
<entry>Number of deadlocks detected in this database</entry> <entry>Number of deadlocks detected in this database</entry>
</row> </row>
<row> <row>
<entry><structfield>block_read_time</></entry> <entry><structfield>blk_read_time</></entry>
<entry><type>bigint</></entry> <entry><type>bigint</></entry>
<entry>Time spent reading data file blocks by backends in this database, <entry>Time spent reading data file blocks by backends in this database,
in milliseconds</entry> in milliseconds</entry>
</row> </row>
<row> <row>
<entry><structfield>block_write_time</></entry> <entry><structfield>blk_write_time</></entry>
<entry><type>bigint</></entry> <entry><type>bigint</></entry>
<entry>Time spent writing data file blocks by backends in this database, <entry>Time spent writing data file blocks by backends in this database,
in milliseconds</entry> in milliseconds</entry>
...@@ -1709,8 +1709,6 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, ...@@ -1709,8 +1709,6 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
<entry><literal><function>pg_stat_get_backend_start(integer)</function></literal></entry> <entry><literal><function>pg_stat_get_backend_start(integer)</function></literal></entry>
<entry><type>timestamp with time zone</type></entry> <entry><type>timestamp with time zone</type></entry>
<entry>Time when this process was started</entry> <entry>Time when this process was started</entry>
<entry>
</entry>
</row> </row>
<row> <row>
......
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
</row> </row>
<row> <row>
<entry><structfield>time_read</structfield></entry> <entry><structfield>blk_read_time</structfield></entry>
<entry><type>double precision</type></entry> <entry><type>double precision</type></entry>
<entry></entry> <entry></entry>
<entry> <entry>
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
</row> </row>
<row> <row>
<entry><structfield>time_write</structfield></entry> <entry><structfield>blk_write_time</structfield></entry>
<entry><type>double precision</type></entry> <entry><type>double precision</type></entry>
<entry></entry> <entry></entry>
<entry> <entry>
......
...@@ -604,8 +604,8 @@ CREATE VIEW pg_stat_database AS ...@@ -604,8 +604,8 @@ CREATE VIEW pg_stat_database AS
pg_stat_get_db_temp_files(D.oid) AS temp_files, pg_stat_get_db_temp_files(D.oid) AS temp_files,
pg_stat_get_db_temp_bytes(D.oid) AS temp_bytes, pg_stat_get_db_temp_bytes(D.oid) AS temp_bytes,
pg_stat_get_db_deadlocks(D.oid) AS deadlocks, pg_stat_get_db_deadlocks(D.oid) AS deadlocks,
pg_stat_get_db_block_time_read(D.oid) / 1000 AS block_read_time, pg_stat_get_db_blk_read_time(D.oid) / 1000 AS blk_read_time,
pg_stat_get_db_block_time_write(D.oid) / 1000 AS block_write_time, pg_stat_get_db_blk_write_time(D.oid) / 1000 AS blk_write_time,
pg_stat_get_db_stat_reset_time(D.oid) AS stats_reset pg_stat_get_db_stat_reset_time(D.oid) AS stats_reset
FROM pg_database D; FROM pg_database D;
......
...@@ -1236,8 +1236,8 @@ ExplainNode(PlanState *planstate, List *ancestors, ...@@ -1236,8 +1236,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
usage->local_blks_written > 0); usage->local_blks_written > 0);
bool has_temp = (usage->temp_blks_read > 0 || bool has_temp = (usage->temp_blks_read > 0 ||
usage->temp_blks_written > 0); usage->temp_blks_written > 0);
bool has_timing = (!INSTR_TIME_IS_ZERO(usage->time_read) || bool has_timing = (!INSTR_TIME_IS_ZERO(usage->blk_read_time) ||
!INSTR_TIME_IS_ZERO(usage->time_write)); !INSTR_TIME_IS_ZERO(usage->blk_write_time));
/* Show only positive counter values. */ /* Show only positive counter values. */
if (has_shared || has_local || has_temp) if (has_shared || has_local || has_temp)
...@@ -1299,12 +1299,12 @@ ExplainNode(PlanState *planstate, List *ancestors, ...@@ -1299,12 +1299,12 @@ ExplainNode(PlanState *planstate, List *ancestors,
{ {
appendStringInfoSpaces(es->str, es->indent * 2); appendStringInfoSpaces(es->str, es->indent * 2);
appendStringInfoString(es->str, "I/O Timings:"); appendStringInfoString(es->str, "I/O Timings:");
if (!INSTR_TIME_IS_ZERO(usage->time_read)) if (!INSTR_TIME_IS_ZERO(usage->blk_read_time))
appendStringInfo(es->str, " read=%0.2f", appendStringInfo(es->str, " read=%0.3f",
INSTR_TIME_GET_MILLISEC(usage->time_read)); INSTR_TIME_GET_MILLISEC(usage->blk_read_time));
if (!INSTR_TIME_IS_ZERO(usage->time_write)) if (!INSTR_TIME_IS_ZERO(usage->blk_write_time))
appendStringInfo(es->str, " write=%0.2f", appendStringInfo(es->str, " write=%0.3f",
INSTR_TIME_GET_MILLISEC(usage->time_write)); INSTR_TIME_GET_MILLISEC(usage->blk_write_time));
appendStringInfoChar(es->str, '\n'); appendStringInfoChar(es->str, '\n');
} }
} }
...@@ -1320,8 +1320,8 @@ ExplainNode(PlanState *planstate, List *ancestors, ...@@ -1320,8 +1320,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
ExplainPropertyLong("Local Written Blocks", usage->local_blks_written, es); ExplainPropertyLong("Local Written Blocks", usage->local_blks_written, es);
ExplainPropertyLong("Temp Read Blocks", usage->temp_blks_read, es); ExplainPropertyLong("Temp Read Blocks", usage->temp_blks_read, es);
ExplainPropertyLong("Temp Written Blocks", usage->temp_blks_written, es); ExplainPropertyLong("Temp Written Blocks", usage->temp_blks_written, es);
ExplainPropertyFloat("I/O Read Time", INSTR_TIME_GET_MILLISEC(usage->time_read), 3, es); ExplainPropertyFloat("I/O Read Time", INSTR_TIME_GET_MILLISEC(usage->blk_read_time), 3, es);
ExplainPropertyFloat("I/O Write Time", INSTR_TIME_GET_MILLISEC(usage->time_write), 3, es); ExplainPropertyFloat("I/O Write Time", INSTR_TIME_GET_MILLISEC(usage->blk_write_time), 3, es);
} }
} }
......
...@@ -145,6 +145,8 @@ BufferUsageAccumDiff(BufferUsage *dst, ...@@ -145,6 +145,8 @@ BufferUsageAccumDiff(BufferUsage *dst,
dst->local_blks_written += add->local_blks_written - sub->local_blks_written; dst->local_blks_written += add->local_blks_written - sub->local_blks_written;
dst->temp_blks_read += add->temp_blks_read - sub->temp_blks_read; dst->temp_blks_read += add->temp_blks_read - sub->temp_blks_read;
dst->temp_blks_written += add->temp_blks_written - sub->temp_blks_written; dst->temp_blks_written += add->temp_blks_written - sub->temp_blks_written;
INSTR_TIME_ACCUM_DIFF(dst->time_read, add->time_read, sub->time_read); INSTR_TIME_ACCUM_DIFF(dst->blk_read_time,
INSTR_TIME_ACCUM_DIFF(dst->time_write, add->time_write, sub->time_write); add->blk_read_time, sub->blk_read_time);
INSTR_TIME_ACCUM_DIFF(dst->blk_write_time,
add->blk_write_time, sub->blk_write_time);
} }
...@@ -197,8 +197,8 @@ static PgStat_SubXactStatus *pgStatXactStack = NULL; ...@@ -197,8 +197,8 @@ static PgStat_SubXactStatus *pgStatXactStack = NULL;
static int pgStatXactCommit = 0; static int pgStatXactCommit = 0;
static int pgStatXactRollback = 0; static int pgStatXactRollback = 0;
PgStat_Counter pgStatBlockTimeRead = 0; PgStat_Counter pgStatBlockReadTime = 0;
PgStat_Counter pgStatBlockTimeWrite = 0; PgStat_Counter pgStatBlockWriteTime = 0;
/* Record that's written to 2PC state file when pgstat state is persisted */ /* Record that's written to 2PC state file when pgstat state is persisted */
typedef struct TwoPhasePgStatRecord typedef struct TwoPhasePgStatRecord
...@@ -791,19 +791,19 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg) ...@@ -791,19 +791,19 @@ pgstat_send_tabstat(PgStat_MsgTabstat *tsmsg)
{ {
tsmsg->m_xact_commit = pgStatXactCommit; tsmsg->m_xact_commit = pgStatXactCommit;
tsmsg->m_xact_rollback = pgStatXactRollback; tsmsg->m_xact_rollback = pgStatXactRollback;
tsmsg->m_block_time_read = pgStatBlockTimeRead; tsmsg->m_block_read_time = pgStatBlockReadTime;
tsmsg->m_block_time_write = pgStatBlockTimeWrite; tsmsg->m_block_write_time = pgStatBlockWriteTime;
pgStatXactCommit = 0; pgStatXactCommit = 0;
pgStatXactRollback = 0; pgStatXactRollback = 0;
pgStatBlockTimeRead = 0; pgStatBlockReadTime = 0;
pgStatBlockTimeWrite = 0; pgStatBlockWriteTime = 0;
} }
else else
{ {
tsmsg->m_xact_commit = 0; tsmsg->m_xact_commit = 0;
tsmsg->m_xact_rollback = 0; tsmsg->m_xact_rollback = 0;
tsmsg->m_block_time_read = 0; tsmsg->m_block_read_time = 0;
tsmsg->m_block_time_write = 0; tsmsg->m_block_write_time = 0;
} }
n = tsmsg->m_nentries; n = tsmsg->m_nentries;
...@@ -3360,8 +3360,8 @@ pgstat_get_db_entry(Oid databaseid, bool create) ...@@ -3360,8 +3360,8 @@ pgstat_get_db_entry(Oid databaseid, bool create)
result->n_temp_files = 0; result->n_temp_files = 0;
result->n_temp_bytes = 0; result->n_temp_bytes = 0;
result->n_deadlocks = 0; result->n_deadlocks = 0;
result->n_block_time_read = 0; result->n_block_read_time = 0;
result->n_block_time_write = 0; result->n_block_write_time = 0;
result->stat_reset_timestamp = GetCurrentTimestamp(); result->stat_reset_timestamp = GetCurrentTimestamp();
...@@ -4080,8 +4080,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) ...@@ -4080,8 +4080,8 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len)
*/ */
dbentry->n_xact_commit += (PgStat_Counter) (msg->m_xact_commit); dbentry->n_xact_commit += (PgStat_Counter) (msg->m_xact_commit);
dbentry->n_xact_rollback += (PgStat_Counter) (msg->m_xact_rollback); dbentry->n_xact_rollback += (PgStat_Counter) (msg->m_xact_rollback);
dbentry->n_block_time_read += msg->m_block_time_read; dbentry->n_block_read_time += msg->m_block_read_time;
dbentry->n_block_time_write += msg->m_block_time_write; dbentry->n_block_write_time += msg->m_block_write_time;
/* /*
* Process all table entries in the message. * Process all table entries in the message.
...@@ -4278,8 +4278,8 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) ...@@ -4278,8 +4278,8 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len)
dbentry->n_temp_bytes = 0; dbentry->n_temp_bytes = 0;
dbentry->n_temp_files = 0; dbentry->n_temp_files = 0;
dbentry->n_deadlocks = 0; dbentry->n_deadlocks = 0;
dbentry->n_block_time_read = 0; dbentry->n_block_read_time = 0;
dbentry->n_block_time_write = 0; dbentry->n_block_write_time = 0;
dbentry->stat_reset_timestamp = GetCurrentTimestamp(); dbentry->stat_reset_timestamp = GetCurrentTimestamp();
......
...@@ -451,7 +451,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, ...@@ -451,7 +451,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
INSTR_TIME_SET_CURRENT(io_time); INSTR_TIME_SET_CURRENT(io_time);
INSTR_TIME_SUBTRACT(io_time, io_start); INSTR_TIME_SUBTRACT(io_time, io_start);
pgstat_count_buffer_read_time(INSTR_TIME_GET_MICROSEC(io_time)); pgstat_count_buffer_read_time(INSTR_TIME_GET_MICROSEC(io_time));
INSTR_TIME_ADD(pgBufferUsage.time_read, io_time); INSTR_TIME_ADD(pgBufferUsage.blk_read_time, io_time);
} }
/* check for garbage data */ /* check for garbage data */
...@@ -1952,7 +1952,7 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln) ...@@ -1952,7 +1952,7 @@ FlushBuffer(volatile BufferDesc *buf, SMgrRelation reln)
INSTR_TIME_SET_CURRENT(io_time); INSTR_TIME_SET_CURRENT(io_time);
INSTR_TIME_SUBTRACT(io_time, io_start); INSTR_TIME_SUBTRACT(io_time, io_start);
pgstat_count_buffer_write_time(INSTR_TIME_GET_MICROSEC(io_time)); pgstat_count_buffer_write_time(INSTR_TIME_GET_MICROSEC(io_time));
INSTR_TIME_ADD(pgBufferUsage.time_write, io_time); INSTR_TIME_ADD(pgBufferUsage.blk_write_time, io_time);
} }
pgBufferUsage.shared_blks_written++; pgBufferUsage.shared_blks_written++;
......
...@@ -82,8 +82,8 @@ extern Datum pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS); ...@@ -82,8 +82,8 @@ extern Datum pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS); extern Datum pg_stat_get_db_stat_reset_time(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_temp_files(PG_FUNCTION_ARGS); extern Datum pg_stat_get_db_temp_files(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_temp_bytes(PG_FUNCTION_ARGS); extern Datum pg_stat_get_db_temp_bytes(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_block_time_read(PG_FUNCTION_ARGS); extern Datum pg_stat_get_db_blk_read_time(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_db_block_time_write(PG_FUNCTION_ARGS); extern Datum pg_stat_get_db_blk_write_time(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS); extern Datum pg_stat_get_bgwriter_timed_checkpoints(PG_FUNCTION_ARGS);
extern Datum pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS); extern Datum pg_stat_get_bgwriter_requested_checkpoints(PG_FUNCTION_ARGS);
...@@ -1362,7 +1362,7 @@ pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS) ...@@ -1362,7 +1362,7 @@ pg_stat_get_db_deadlocks(PG_FUNCTION_ARGS)
} }
Datum Datum
pg_stat_get_db_block_time_read(PG_FUNCTION_ARGS) pg_stat_get_db_blk_read_time(PG_FUNCTION_ARGS)
{ {
Oid dbid = PG_GETARG_OID(0); Oid dbid = PG_GETARG_OID(0);
int64 result; int64 result;
...@@ -1371,13 +1371,13 @@ pg_stat_get_db_block_time_read(PG_FUNCTION_ARGS) ...@@ -1371,13 +1371,13 @@ pg_stat_get_db_block_time_read(PG_FUNCTION_ARGS)
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0; result = 0;
else else
result = (int64) (dbentry->n_block_time_read); result = (int64) (dbentry->n_block_read_time);
PG_RETURN_INT64(result); PG_RETURN_INT64(result);
} }
Datum Datum
pg_stat_get_db_block_time_write(PG_FUNCTION_ARGS) pg_stat_get_db_blk_write_time(PG_FUNCTION_ARGS)
{ {
Oid dbid = PG_GETARG_OID(0); Oid dbid = PG_GETARG_OID(0);
int64 result; int64 result;
...@@ -1386,7 +1386,7 @@ pg_stat_get_db_block_time_write(PG_FUNCTION_ARGS) ...@@ -1386,7 +1386,7 @@ pg_stat_get_db_block_time_write(PG_FUNCTION_ARGS)
if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL) if ((dbentry = pgstat_fetch_stat_dbentry(dbid)) == NULL)
result = 0; result = 0;
else else
result = (int64) (dbentry->n_block_time_write); result = (int64) (dbentry->n_block_write_time);
PG_RETURN_INT64(result); PG_RETURN_INT64(result);
} }
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201204201 #define CATALOG_VERSION_NO 201204291
#endif #endif
...@@ -2662,9 +2662,9 @@ DATA(insert OID = 3150 ( pg_stat_get_db_temp_files PGNSP PGUID 12 1 0 0 0 f f f ...@@ -2662,9 +2662,9 @@ DATA(insert OID = 3150 ( pg_stat_get_db_temp_files PGNSP PGUID 12 1 0 0 0 f f f
DESCR("statistics: number of temporary files written"); DESCR("statistics: number of temporary files written");
DATA(insert OID = 3151 ( pg_stat_get_db_temp_bytes PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_temp_bytes _null_ _null_ _null_ )); DATA(insert OID = 3151 ( pg_stat_get_db_temp_bytes PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_temp_bytes _null_ _null_ _null_ ));
DESCR("statistics: number of bytes in temporary files written"); DESCR("statistics: number of bytes in temporary files written");
DATA(insert OID = 2844 ( pg_stat_get_db_block_time_read PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_block_time_read _null_ _null_ _null_ )); DATA(insert OID = 2844 ( pg_stat_get_db_blk_read_time PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_blk_read_time _null_ _null_ _null_ ));
DESCR("statistics: block read time in microseconds"); DESCR("statistics: block read time in microseconds");
DATA(insert OID = 2845 ( pg_stat_get_db_block_time_write PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_block_time_write _null_ _null_ _null_ )); DATA(insert OID = 2845 ( pg_stat_get_db_blk_write_time PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 20 "26" _null_ _null_ _null_ _null_ pg_stat_get_db_blk_write_time _null_ _null_ _null_ ));
DESCR("statistics: block write time in microseconds"); DESCR("statistics: block write time in microseconds");
DATA(insert OID = 2769 ( pg_stat_get_bgwriter_timed_checkpoints PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 20 "" _null_ _null_ _null_ _null_ pg_stat_get_bgwriter_timed_checkpoints _null_ _null_ _null_ )); DATA(insert OID = 2769 ( pg_stat_get_bgwriter_timed_checkpoints PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 20 "" _null_ _null_ _null_ _null_ pg_stat_get_bgwriter_timed_checkpoints _null_ _null_ _null_ ));
DESCR("statistics: number of timed checkpoints started by the bgwriter"); DESCR("statistics: number of timed checkpoints started by the bgwriter");
......
...@@ -18,18 +18,18 @@ ...@@ -18,18 +18,18 @@
typedef struct BufferUsage typedef struct BufferUsage
{ {
long shared_blks_hit; /* # of shared buffer hits */ long shared_blks_hit; /* # of shared buffer hits */
long shared_blks_read; /* # of shared disk blocks read */ long shared_blks_read; /* # of shared disk blocks read */
long shared_blks_dirtied; /* # of shared blocks dirtied */ long shared_blks_dirtied; /* # of shared blocks dirtied */
long shared_blks_written; /* # of shared disk blocks written */ long shared_blks_written; /* # of shared disk blocks written */
long local_blks_hit; /* # of local buffer hits */ long local_blks_hit; /* # of local buffer hits */
long local_blks_read; /* # of local disk blocks read */ long local_blks_read; /* # of local disk blocks read */
long local_blks_dirtied; /* # of shared blocks dirtied */ long local_blks_dirtied; /* # of shared blocks dirtied */
long local_blks_written; /* # of local disk blocks written */ long local_blks_written; /* # of local disk blocks written */
long temp_blks_read; /* # of temp blocks read */ long temp_blks_read; /* # of temp blocks read */
long temp_blks_written; /* # of temp blocks written */ long temp_blks_written; /* # of temp blocks written */
instr_time time_read; /* time spent reading */ instr_time blk_read_time; /* time spent reading */
instr_time time_write; /* time spent writing */ instr_time blk_write_time; /* time spent writing */
} BufferUsage; } BufferUsage;
/* Flag bits included in InstrAlloc's instrument_options bitmask */ /* Flag bits included in InstrAlloc's instrument_options bitmask */
......
...@@ -233,8 +233,8 @@ typedef struct PgStat_MsgTabstat ...@@ -233,8 +233,8 @@ typedef struct PgStat_MsgTabstat
int m_nentries; int m_nentries;
int m_xact_commit; int m_xact_commit;
int m_xact_rollback; int m_xact_rollback;
PgStat_Counter m_block_time_read; PgStat_Counter m_block_read_time;
PgStat_Counter m_block_time_write; PgStat_Counter m_block_write_time;
PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES]; PgStat_TableEntry m_entry[PGSTAT_NUM_TABENTRIES];
} PgStat_MsgTabstat; } PgStat_MsgTabstat;
...@@ -540,8 +540,8 @@ typedef struct PgStat_StatDBEntry ...@@ -540,8 +540,8 @@ typedef struct PgStat_StatDBEntry
PgStat_Counter n_temp_files; PgStat_Counter n_temp_files;
PgStat_Counter n_temp_bytes; PgStat_Counter n_temp_bytes;
PgStat_Counter n_deadlocks; PgStat_Counter n_deadlocks;
PgStat_Counter n_block_time_read; /* times in microseconds */ PgStat_Counter n_block_read_time; /* times in microseconds */
PgStat_Counter n_block_time_write; PgStat_Counter n_block_write_time;
TimestampTz stat_reset_timestamp; TimestampTz stat_reset_timestamp;
...@@ -732,8 +732,8 @@ extern PgStat_MsgBgWriter BgWriterStats; ...@@ -732,8 +732,8 @@ extern PgStat_MsgBgWriter BgWriterStats;
/* /*
* Updated by pgstat_count_time_* macros. * Updated by pgstat_count_time_* macros.
*/ */
extern PgStat_Counter pgStatBlockTimeRead; extern PgStat_Counter pgStatBlockReadTime;
extern PgStat_Counter pgStatBlockTimeWrite; extern PgStat_Counter pgStatBlockWriteTime;
/* ---------- /* ----------
* Functions called from postmaster * Functions called from postmaster
...@@ -831,9 +831,9 @@ extern void pgstat_initstats(Relation rel); ...@@ -831,9 +831,9 @@ extern void pgstat_initstats(Relation rel);
(rel)->pgstat_info->t_counts.t_blocks_hit++; \ (rel)->pgstat_info->t_counts.t_blocks_hit++; \
} while (0) } while (0)
#define pgstat_count_buffer_read_time(n) \ #define pgstat_count_buffer_read_time(n) \
pgStatBlockTimeRead += (n); (pgStatBlockReadTime += (n))
#define pgstat_count_buffer_write_time(n) \ #define pgstat_count_buffer_write_time(n) \
pgStatBlockTimeWrite += (n); (pgStatBlockWriteTime += (n))
extern void pgstat_count_heap_insert(Relation rel, int n); extern void pgstat_count_heap_insert(Relation rel, int n);
extern void pgstat_count_heap_update(Relation rel, bool hot); extern void pgstat_count_heap_update(Relation rel, bool hot);
......
...@@ -1296,7 +1296,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem ...@@ -1296,7 +1296,7 @@ SELECT viewname, definition FROM pg_views WHERE schemaname <> 'information_schem
pg_stat_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])); pg_stat_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, n.nspname AS schemaname, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM (((pg_class c JOIN pg_index x ON ((c.oid = x.indrelid))) JOIN pg_class i ON ((i.oid = x.indexrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"]));
pg_stat_all_tables | SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, (sum(pg_stat_get_numscans(i.indexrelid)))::bigint AS idx_scan, ((sum(pg_stat_get_tuples_fetched(i.indexrelid)))::bigint + pg_stat_get_tuples_fetched(c.oid)) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, pg_stat_get_live_tuples(c.oid) AS n_live_tup, pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, pg_stat_get_last_analyze_time(c.oid) AS last_analyze, pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze, pg_stat_get_vacuum_count(c.oid) AS vacuum_count, pg_stat_get_autovacuum_count(c.oid) AS autovacuum_count, pg_stat_get_analyze_count(c.oid) AS analyze_count, pg_stat_get_autoanalyze_count(c.oid) AS autoanalyze_count FROM ((pg_class c LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])) GROUP BY c.oid, n.nspname, c.relname; pg_stat_all_tables | SELECT c.oid AS relid, n.nspname AS schemaname, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, (sum(pg_stat_get_numscans(i.indexrelid)))::bigint AS idx_scan, ((sum(pg_stat_get_tuples_fetched(i.indexrelid)))::bigint + pg_stat_get_tuples_fetched(c.oid)) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del, pg_stat_get_tuples_hot_updated(c.oid) AS n_tup_hot_upd, pg_stat_get_live_tuples(c.oid) AS n_live_tup, pg_stat_get_dead_tuples(c.oid) AS n_dead_tup, pg_stat_get_last_vacuum_time(c.oid) AS last_vacuum, pg_stat_get_last_autovacuum_time(c.oid) AS last_autovacuum, pg_stat_get_last_analyze_time(c.oid) AS last_analyze, pg_stat_get_last_autoanalyze_time(c.oid) AS last_autoanalyze, pg_stat_get_vacuum_count(c.oid) AS vacuum_count, pg_stat_get_autovacuum_count(c.oid) AS autovacuum_count, pg_stat_get_analyze_count(c.oid) AS analyze_count, pg_stat_get_autoanalyze_count(c.oid) AS autoanalyze_count FROM ((pg_class c LEFT JOIN pg_index i ON ((c.oid = i.indrelid))) LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = ANY (ARRAY['r'::"char", 't'::"char"])) GROUP BY c.oid, n.nspname, c.relname;
pg_stat_bgwriter | SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed, pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req, pg_stat_get_checkpoint_write_time() AS checkpoint_write_time, pg_stat_get_checkpoint_sync_time() AS checkpoint_sync_time, pg_stat_get_bgwriter_buf_written_checkpoints() AS buffers_checkpoint, pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean, pg_stat_get_bgwriter_maxwritten_clean() AS maxwritten_clean, pg_stat_get_buf_written_backend() AS buffers_backend, pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync, pg_stat_get_buf_alloc() AS buffers_alloc, pg_stat_get_bgwriter_stat_reset_time() AS stats_reset; pg_stat_bgwriter | SELECT pg_stat_get_bgwriter_timed_checkpoints() AS checkpoints_timed, pg_stat_get_bgwriter_requested_checkpoints() AS checkpoints_req, pg_stat_get_checkpoint_write_time() AS checkpoint_write_time, pg_stat_get_checkpoint_sync_time() AS checkpoint_sync_time, pg_stat_get_bgwriter_buf_written_checkpoints() AS buffers_checkpoint, pg_stat_get_bgwriter_buf_written_clean() AS buffers_clean, pg_stat_get_bgwriter_maxwritten_clean() AS maxwritten_clean, pg_stat_get_buf_written_backend() AS buffers_backend, pg_stat_get_buf_fsync_backend() AS buffers_backend_fsync, pg_stat_get_buf_alloc() AS buffers_alloc, pg_stat_get_bgwriter_stat_reset_time() AS stats_reset;
pg_stat_database | SELECT d.oid AS datid, d.datname, pg_stat_get_db_numbackends(d.oid) AS numbackends, pg_stat_get_db_xact_commit(d.oid) AS xact_commit, pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback, (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read, pg_stat_get_db_blocks_hit(d.oid) AS blks_hit, pg_stat_get_db_tuples_returned(d.oid) AS tup_returned, pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched, pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted, pg_stat_get_db_tuples_updated(d.oid) AS tup_updated, pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted, pg_stat_get_db_conflict_all(d.oid) AS conflicts, pg_stat_get_db_temp_files(d.oid) AS temp_files, pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes, pg_stat_get_db_deadlocks(d.oid) AS deadlocks, (pg_stat_get_db_block_time_read(d.oid) / 1000) AS block_read_time, (pg_stat_get_db_block_time_write(d.oid) / 1000) AS block_write_time, pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset FROM pg_database d; pg_stat_database | SELECT d.oid AS datid, d.datname, pg_stat_get_db_numbackends(d.oid) AS numbackends, pg_stat_get_db_xact_commit(d.oid) AS xact_commit, pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback, (pg_stat_get_db_blocks_fetched(d.oid) - pg_stat_get_db_blocks_hit(d.oid)) AS blks_read, pg_stat_get_db_blocks_hit(d.oid) AS blks_hit, pg_stat_get_db_tuples_returned(d.oid) AS tup_returned, pg_stat_get_db_tuples_fetched(d.oid) AS tup_fetched, pg_stat_get_db_tuples_inserted(d.oid) AS tup_inserted, pg_stat_get_db_tuples_updated(d.oid) AS tup_updated, pg_stat_get_db_tuples_deleted(d.oid) AS tup_deleted, pg_stat_get_db_conflict_all(d.oid) AS conflicts, pg_stat_get_db_temp_files(d.oid) AS temp_files, pg_stat_get_db_temp_bytes(d.oid) AS temp_bytes, pg_stat_get_db_deadlocks(d.oid) AS deadlocks, (pg_stat_get_db_blk_read_time(d.oid) / 1000) AS blk_read_time, (pg_stat_get_db_blk_write_time(d.oid) / 1000) AS blk_write_time, pg_stat_get_db_stat_reset_time(d.oid) AS stats_reset FROM pg_database d;
pg_stat_database_conflicts | SELECT d.oid AS datid, d.datname, pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace, pg_stat_get_db_conflict_lock(d.oid) AS confl_lock, pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot, pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin, pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock FROM pg_database d; pg_stat_database_conflicts | SELECT d.oid AS datid, d.datname, pg_stat_get_db_conflict_tablespace(d.oid) AS confl_tablespace, pg_stat_get_db_conflict_lock(d.oid) AS confl_lock, pg_stat_get_db_conflict_snapshot(d.oid) AS confl_snapshot, pg_stat_get_db_conflict_bufferpin(d.oid) AS confl_bufferpin, pg_stat_get_db_conflict_startup_deadlock(d.oid) AS confl_deadlock FROM pg_database d;
pg_stat_replication | SELECT s.pid, s.usesysid, u.rolname AS usename, s.application_name, s.client_addr, s.client_hostname, s.client_port, s.backend_start, w.state, w.sent_location, w.write_location, w.flush_location, w.replay_location, w.sync_priority, w.sync_state FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, waiting, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port), pg_authid u, pg_stat_get_wal_senders() w(pid, state, sent_location, write_location, flush_location, replay_location, sync_priority, sync_state) WHERE ((s.usesysid = u.oid) AND (s.pid = w.pid)); pg_stat_replication | SELECT s.pid, s.usesysid, u.rolname AS usename, s.application_name, s.client_addr, s.client_hostname, s.client_port, s.backend_start, w.state, w.sent_location, w.write_location, w.flush_location, w.replay_location, w.sync_priority, w.sync_state FROM pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, waiting, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port), pg_authid u, pg_stat_get_wal_senders() w(pid, state, sent_location, write_location, flush_location, replay_location, sync_priority, sync_state) WHERE ((s.usesysid = u.oid) AND (s.pid = w.pid));
pg_stat_sys_indexes | SELECT pg_stat_all_indexes.relid, pg_stat_all_indexes.indexrelid, pg_stat_all_indexes.schemaname, pg_stat_all_indexes.relname, pg_stat_all_indexes.indexrelname, pg_stat_all_indexes.idx_scan, pg_stat_all_indexes.idx_tup_read, pg_stat_all_indexes.idx_tup_fetch FROM pg_stat_all_indexes WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text)); pg_stat_sys_indexes | SELECT pg_stat_all_indexes.relid, pg_stat_all_indexes.indexrelid, pg_stat_all_indexes.schemaname, pg_stat_all_indexes.relname, pg_stat_all_indexes.indexrelname, pg_stat_all_indexes.idx_scan, pg_stat_all_indexes.idx_tup_read, pg_stat_all_indexes.idx_tup_fetch FROM pg_stat_all_indexes WHERE ((pg_stat_all_indexes.schemaname = ANY (ARRAY['pg_catalog'::name, 'information_schema'::name])) OR (pg_stat_all_indexes.schemaname ~ '^pg_toast'::text));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment