X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3A41054054 for ; Thu, 14 Apr 2005 20:26:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71533-01 for ; Thu, 14 Apr 2005 23:26:14 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 445FA54042 for ; Thu, 14 Apr 2005 20:26:14 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j3ENQ9lm027510; Thu, 14 Apr 2005 19:26:09 -0400 (EDT) To: Greg Stark Cc: Andrew Sullivan , pgsql-sql@postgresql.org Subject: Re: row-attribute in EXPLAIN-output doesn't match count(*) 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> Comments: In-reply-to Greg Stark message dated "14 Apr 2005 15:44:57 -0400" Date: Thu, 14 Apr 2005 19:26:09 -0400 Message-ID: <27509.1113521169@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/215 X-Sequence-Number: 21108 Greg Stark 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