Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9A9561337B54 for ; Wed, 19 Jan 2011 14:32:05 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 06336-04 for ; Wed, 19 Jan 2011 18:31:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.anarazel.de (mail.anarazel.de [217.115.131.40]) by mail.postgresql.org (Postfix) with ESMTP id 5C6DF1337B5D for ; Wed, 19 Jan 2011 14:31:57 -0400 (AST) Received: from alap2.localnet (p579FB3C8.dip.t-dialin.net [87.159.179.200]) by mail.anarazel.de (Postfix) with ESMTPSA id 6420A448007; Wed, 19 Jan 2011 19:31:55 +0100 (CET) From: Andres Freund To: pgsql-performance@postgresql.org Subject: Re: the XID question Date: Wed, 19 Jan 2011 19:31:51 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.37-andres-03737-g0c21e3a; KDE/4.5.95; x86_64; ; ) Cc: Chris Browne References: <4D36A35302000025000397CC@gw.wicourts.gov> <878vyg9399.fsf@cbbrowne.afilias-int.info> In-Reply-To: <878vyg9399.fsf@cbbrowne.afilias-int.info> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201101191931.52841.andres@anarazel.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/172 X-Sequence-Number: 41959 On Wednesday, January 19, 2011 07:06:58 PM Chris Browne wrote: > Kevin.Grittner@wicourts.gov ("Kevin Grittner") writes: > > Filip Rembia*kowski wrote: > >> 2011/1/19 Charles.Hou : > >>> " select * from mybook" SQL command also increase the XID ? > >> > >> Yes. Single SELECT is a transaction. Hence, it needs a transaction > >> ID. > > > > No, not in recent versions of PostgreSQL. There's virtual > > transaction ID, too; which is all that's needed unless the > > transaction writes something. > > > > Also, as a fine point, if you use explicit database transactions > > (with BEGIN or START TRANSACTION) then you normally get one XID for > > the entire transaction, unless you use SAVEPOINTs. > > Erm, "not *necessarily* in recent versions of PostgreSQL." > > A read-only transaction won't consume XIDs, but if you don't expressly > declare it read-only, they're still liable to get eaten... No. The Xid is generally only allocated at the first place a real xid is needed. See GetCurrentTransactionId, AssignTransactionId in xact.c and the caller of the former. Andres