Thread: Re: [PATCHES] Transaction start in pg_stat_activity

Re: [PATCHES] Transaction start in pg_stat_activity

From
Tom Lane
Date:
"Simon Riggs" <simon@2ndquadrant.com> writes:
> Great idea. Would it be appropriate to show the time the current
> snapshot was taken also/instead?

There is no way we are putting a gettimeofday() call into
GetSnapshotData.  I thought you were focused on performance??

            regards, tom lane

Re: [PATCHES] Transaction start in pg_stat_activity

From
"Simon Riggs"
Date:
On Mon, 2006-11-20 at 10:58 -0500, Tom Lane wrote:
> "Simon Riggs" <simon@2ndquadrant.com> writes:
> > Great idea. Would it be appropriate to show the time the current
> > snapshot was taken also/instead?
>
> There is no way we are putting a gettimeofday() call into
> GetSnapshotData.  I thought you were focused on performance??

LOL.

My understanding was there was already a gettimeofday() call per
statement which is displayed in pg_stat_activity. It seems relatively
straightforward to have another column which is *not* updated for each
statement when we are in SERIALIZABLE mode and CommandId > 1.

So I wasn't talking about issuing any additional gettimeofday() calls at
all. :-)

--
  Simon Riggs
  EnterpriseDB   http://www.enterprisedb.com



Re: [PATCHES] Transaction start in pg_stat_activity

From
Tom Lane
Date:
"Simon Riggs" <simon@2ndquadrant.com> writes:
> On Mon, 2006-11-20 at 10:58 -0500, Tom Lane wrote:
>> There is no way we are putting a gettimeofday() call into
>> GetSnapshotData.  I thought you were focused on performance??

> My understanding was there was already a gettimeofday() call per
> statement which is displayed in pg_stat_activity. It seems relatively
> straightforward to have another column which is *not* updated for each
> statement when we are in SERIALIZABLE mode and CommandId > 1.

What for?  The proposal already covers transaction start and statement
start, and those are the only two timestamps available (without adding
extra gettimeofday() calls).  What you propose will merely repeat one of
them.

            regards, tom lane

Re: [PATCHES] Transaction start in pg_stat_activity

From
"Simon Riggs"
Date:
On Mon, 2006-11-20 at 11:32 -0500, Tom Lane wrote:
> "Simon Riggs" <simon@2ndquadrant.com> writes:
> > On Mon, 2006-11-20 at 10:58 -0500, Tom Lane wrote:
> >> There is no way we are putting a gettimeofday() call into
> >> GetSnapshotData.  I thought you were focused on performance??
>
> > My understanding was there was already a gettimeofday() call per
> > statement which is displayed in pg_stat_activity. It seems relatively
> > straightforward to have another column which is *not* updated for each
> > statement when we are in SERIALIZABLE mode and CommandId > 1.
>
> What for?  The proposal already covers transaction start and statement
> start, and those are the only two timestamps available (without adding
> extra gettimeofday() calls).  What you propose will merely repeat one of
> them.

That's true, but you don't know which one is the snapshot timestamp. To
do that we need to either:
1. record the transaction isolation level of the snapshot, then document
the rule by which one would determine the snapshot timestamp.
2. record the timestamp of the snapshot directly

Either way you need another column.

--
  Simon Riggs
  EnterpriseDB   http://www.enterprisedb.com



Re: [PATCHES] Transaction start in pg_stat_activity

From
Tom Lane
Date:
"Simon Riggs" <simon@2ndquadrant.com> writes:
> That's true, but you don't know which one is the snapshot timestamp.

You're assuming there is such a thing as "the" unique active snapshot,
an assumption I find highly dubious.  In any case, the reasons for
wanting to know which transactions are old have to do with the behavior
of VACUUM, and that only pays attention to the age of the whole
transaction not any individual snapshots.  So I still don't see the
point of cluttering pg_stat_activity with yet more columns.

            regards, tom lane