1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Remove redundant gettimeofday() calls to the extent practical without

changing semantics too much.  statement_timestamp is now set immediately
upon receipt of a client command message, and the various places that used
to do their own gettimeofday() calls to mark command startup are referenced
to that instead.  I have also made stats_command_string use that same
value for pg_stat_activity.query_start for both the command itself and
its eventual replacement by <IDLE> or <idle in transaction>.  There was
some debate about that, but no argument that seemed convincing enough to
justify an extra gettimeofday() call.
This commit is contained in:
Tom Lane
2006-06-20 22:52:00 +00:00
parent 47a37aeebd
commit 27c3e3de09
11 changed files with 269 additions and 226 deletions

View File

@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.129 2006/06/19 01:51:21 tgl Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.130 2006/06/20 22:52:00 tgl Exp $
* ----------
*/
#include "postgres.h"
@ -1368,8 +1368,14 @@ pgstat_bestart(void)
/*
* To minimize the time spent modifying the entry, fetch all the
* needed data first.
*
* If we have a MyProcPort, use its session start time (for consistency,
* and to save a kernel call).
*/
proc_start_timestamp = GetCurrentTimestamp();
if (MyProcPort)
proc_start_timestamp = MyProcPort->SessionStartTime;
else
proc_start_timestamp = GetCurrentTimestamp();
userid = GetSessionUserId();
/*
@ -1464,7 +1470,7 @@ pgstat_report_activity(const char *cmd_str)
* To minimize the time spent modifying the entry, fetch all the
* needed data first.
*/
start_timestamp = GetCurrentTimestamp();
start_timestamp = GetCurrentStatementStartTimestamp();
len = strlen(cmd_str);
len = pg_mbcliplen(cmd_str, len, PGBE_ACTIVITY_SIZE - 1);