diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-20 22:52:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-06-20 22:52:00 +0000 |
commit | 27c3e3de0939d93ae8adb50ab7e00c4a5ff2fa0d (patch) | |
tree | 49a0c81851952447af7bcace3f37e1d7b77c4854 /src/backend/access | |
parent | 47a37aeebdbeb5c242141830586e065256a0aaf6 (diff) | |
download | postgresql-27c3e3de0939d93ae8adb50ab7e00c4a5ff2fa0d.tar.gz postgresql-27c3e3de0939d93ae8adb50ab7e00c4a5ff2fa0d.zip |
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.
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/transam/xact.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index b59cea044b9..3716a85dfb2 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.220 2006/04/25 00:25:17 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.221 2006/06/20 22:51:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -167,9 +167,10 @@ static SubTransactionId currentSubTransactionId; static CommandId currentCommandId; /* - * This is the value of now(), ie, the transaction start time. - * This does not change as we enter and exit subtransactions, so we don't - * keep it inside the TransactionState stack. + * xactStartTimestamp is the value of transaction_timestamp(). + * stmtStartTimestamp is the value of statement_timestamp(). + * These do not change as we enter and exit subtransactions, so we don't + * keep them inside the TransactionState stack. */ static TimestampTz xactStartTimestamp; static TimestampTz stmtStartTimestamp; @@ -1386,7 +1387,9 @@ StartTransaction(void) XactLockTableInsert(s->transactionId); /* - * now() and statement_timestamp() should be the same time + * set transaction_timestamp() (a/k/a now()). We want this to be the + * same as the first command's statement_timestamp(), so don't do a + * fresh GetCurrentTimestamp() call (which'd be expensive anyway). */ xactStartTimestamp = stmtStartTimestamp; |