pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Andrew Sullivan <ajs@crankycanuck.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: row-attribute in EXPLAIN-output doesn't match count(*)
Date: Thu, 14 Apr 2005 19:26:09 -0400
Message-ID: <27509.1113521169@sss.pgh.pa.us> (raw)
In-Reply-To: <8764ypf8hy.fsf@stark.xeocode.com>
References: <200504141838.14705.andreak@officenet.no>
	<425EA496.2030501@archonet.com>
	<200504141921.38476.andreak@officenet.no>
	<20050414173358.GB9027@phlogiston.dyndns.org>
	<8764ypf8hy.fsf@stark.xeocode.com>

Greg Stark <gsstark@mit.edu> writes:
> This is presumably because of the long-standing issue that Postgres takes the
> snapshot as soon as the BEGIN is issued.

No, we don't set the snapshot until the first DML query is issued.  This
is critical for serializable transactions: you have to be able to take
locks before the snapshot is frozen.

There are at least three interesting events involved:
    1  BEGIN command issued
    2  First lock taken (presumably as a consequence of another command)
    3  Transaction snapshot taken (ditto; might be a different command)

We have to start the transaction no later than event #2 since there has
to be something to hold the lock.  But it'd be easy enough to decouple
this from BEGIN, and it'd be good enough to solve the "COMMIT;BEGIN"
problem.

Which of these three times do you think now() ought to correspond to?
I recall having argued that it should be event #3 since that corresponds
to the database snapshot you see.  100% backwards compatibility would
require setting now() at event #1, but will anyone weep if we change that?

			regards, tom lane



view thread (24+ messages)  latest in thread

Message-ID: <27509.1113521169@sss.pgh.pa.us>
Permalink:  ../27509.1113521169@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/27509.1113521169@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gsstark@mit.edu, ajs@crankycanuck.ca
  Subject: Re: row-attribute in EXPLAIN-output doesn't match count(*)
  In-Reply-To: <27509.1113521169@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox