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 78DA353C7C for ; Fri, 15 Apr 2005 02:48:48 -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 70027-02 for ; Fri, 15 Apr 2005 05:48:42 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 80F6953B7C for ; Fri, 15 Apr 2005 02:48:41 -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 j3F5mYUg029944; Fri, 15 Apr 2005 01:48:34 -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: <87fyxsehmz.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> <27509.1113521169@sss.pgh.pa.us> <87fyxsehmz.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "15 Apr 2005 01:25:08 -0400" Date: Fri, 15 Apr 2005 01:48:34 -0400 Message-ID: <29943.1113544114@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/218 X-Sequence-Number: 21111 Greg Stark writes: > So vacuum doesn't really know what tuples are actually visible to the > snapshots actually taken by a transaction? It's making the conservative > estimate that a snapshot could have been taken as early as the start of the > transaction even if no snapshot was taken until later? Not quite, because what it looks at is the snapshot xmin, which each backend publishes in the PGPROC array. A backend that has started a transaction but hasn't yet set its snapshot can be recognized. IIRC the problem comes up indirectly, because such a backend affects the xmins that are computed by *other* transactions. What VACUUM is actually using as the cutoff is the least xmin that it can see anywhere in PGPROC --- and everyone else's xmin will be no higher than the XID of the laggard, even if the laggard hasn't yet set its own xmin. Thinking about this, it seems like xmin might not be quite the right metric for this purpose. It might be worth thinking about whether we could do better with a little more info in PGPROC. regards, tom lane