diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-30 14:02:47 -0400 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-04-30 14:03:33 -0400 |
| commit | 809e7e21af8cd24855f1802524a13bbaa823f929 (patch) | |
| tree | 450387adf177bd65f21de4c29d6428852608a8b4 /src/backend/postmaster/pgstat.c | |
| parent | 26471a51fc833e2ce58a2f16f891256d57dd28c6 (diff) | |
Converge all SQL-level statistics timing values to float8 milliseconds.
This patch adjusts the core statistics views to match the decision already
taken for pg_stat_statements, that values representing elapsed time should
be represented as float8 and measured in milliseconds. By using float8,
we are no longer tied to a specific maximum precision of timing data.
(Internally, it's still microseconds, but we could now change that without
needing changes at the SQL level.)
The columns affected are
pg_stat_bgwriter.checkpoint_write_time
pg_stat_bgwriter.checkpoint_sync_time
pg_stat_database.blk_read_time
pg_stat_database.blk_write_time
pg_stat_user_functions.total_time
pg_stat_user_functions.self_time
pg_stat_xact_user_functions.total_time
pg_stat_xact_user_functions.self_time
The first four of these are new in 9.2, so there is no compatibility issue
from changing them. The others require a release note comment that they
are now double precision (and can show a fractional part) rather than
bigint as before; also their underlying statistics functions now match
the column definitions, instead of returning bigint microseconds.
Diffstat (limited to 'src/backend/postmaster/pgstat.c')
| -rw-r--r-- | src/backend/postmaster/pgstat.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 04f7c1aa711..ac971abb184 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -848,8 +848,8 @@ pgstat_send_funcstats(void) m_ent = &msg.m_entry[msg.m_nentries]; m_ent->f_id = entry->f_id; m_ent->f_numcalls = entry->f_counts.f_numcalls; - m_ent->f_time = INSTR_TIME_GET_MICROSEC(entry->f_counts.f_time); - m_ent->f_time_self = INSTR_TIME_GET_MICROSEC(entry->f_counts.f_time_self); + m_ent->f_total_time = INSTR_TIME_GET_MICROSEC(entry->f_counts.f_total_time); + m_ent->f_self_time = INSTR_TIME_GET_MICROSEC(entry->f_counts.f_self_time); if (++msg.m_nentries >= PGSTAT_NUM_FUNCENTRIES) { @@ -1467,7 +1467,7 @@ pgstat_init_function_usage(FunctionCallInfoData *fcinfo, fcu->fs = &htabent->f_counts; /* save stats for this function, later used to compensate for recursion */ - fcu->save_f_time = htabent->f_counts.f_time; + fcu->save_f_total_time = htabent->f_counts.f_total_time; /* save current backend-wide total time */ fcu->save_total = total_func_time; @@ -1528,19 +1528,19 @@ pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize) INSTR_TIME_ADD(total_func_time, f_self); /* - * Compute the new total f_time as the total elapsed time added to the - * pre-call value of f_time. This is necessary to avoid double-counting - * any time taken by recursive calls of myself. (We do not need any - * similar kluge for self time, since that already excludes any recursive - * calls.) + * Compute the new f_total_time as the total elapsed time added to the + * pre-call value of f_total_time. This is necessary to avoid + * double-counting any time taken by recursive calls of myself. (We do + * not need any similar kluge for self time, since that already excludes + * any recursive calls.) */ - INSTR_TIME_ADD(f_total, fcu->save_f_time); + INSTR_TIME_ADD(f_total, fcu->save_f_total_time); /* update counters in function stats table */ if (finalize) fs->f_numcalls++; - fs->f_time = f_total; - INSTR_TIME_ADD(fs->f_time_self, f_self); + fs->f_total_time = f_total; + INSTR_TIME_ADD(fs->f_self_time, f_self); /* indicate that we have something to send */ have_function_stats = true; @@ -4573,8 +4573,8 @@ pgstat_recv_funcstat(PgStat_MsgFuncstat *msg, int len) * we just got. */ funcentry->f_numcalls = funcmsg->f_numcalls; - funcentry->f_time = funcmsg->f_time; - funcentry->f_time_self = funcmsg->f_time_self; + funcentry->f_total_time = funcmsg->f_total_time; + funcentry->f_self_time = funcmsg->f_self_time; } else { @@ -4582,8 +4582,8 @@ pgstat_recv_funcstat(PgStat_MsgFuncstat *msg, int len) * Otherwise add the values to the existing entry. */ funcentry->f_numcalls += funcmsg->f_numcalls; - funcentry->f_time += funcmsg->f_time; - funcentry->f_time_self += funcmsg->f_time_self; + funcentry->f_total_time += funcmsg->f_total_time; + funcentry->f_self_time += funcmsg->f_self_time; } } } |
