Re: Getting rid of extra gettimeofday() calls - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Getting rid of extra gettimeofday() calls
Date
Msg-id 21318.1150748878@sss.pgh.pa.us
Whole thread Raw
In response to Re: Getting rid of extra gettimeofday() calls  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-hackers
Simon Riggs <simon@2ndquadrant.com> writes:
> Presumably you don't mean *every* client message, just stmt start ones. 

At the moment I've got it setting the statement_timestamp on receipt of
any message that could lead to execution of user-defined code; that
includes Query, Parse, Bind, Execute, FunctionCall.  Possibly we could
dispense with the Bind one but I'm unconvinced.

> Can we set that in GetTransactionSnapshot() - that way a serializable
> transaction won't need to update the time after each statement.

No, that's much too late, unless you want to do major rearrangement of
the times at which reporting actions occur.  Furthermore the entire
point of statement_timestamp is that it advances for new commands within
the same xact, so your proposal amounts to removing statement_timestamp
entirely.

The actual behavior of CVS tip is that transaction_timestamp copies from
statement_timestamp, not vice versa; that seems fine to me.

> Presumably we have to do at least one at the end when doing statement
> logging?

Only if you've got log_duration on.  Per Jim's suggestion, maybe we
could have the <IDLE> activity report advance activity_timestamp only
if log_duration is true, ie, only if it's free to do so.

> I notice there is also one in elog.c for when we have %t set. We
> probably don't need to do both when statement logging.

I'm inclined to think that that one is worth its keep.  Sometimes you
really wanna know exactly when a log message was emitted ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Getting rid of extra gettimeofday() calls
Next
From: Tom Lane
Date:
Subject: Re: Generic Monitoring Framework Proposal