Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id F41761337D03 for ; Tue, 12 Oct 2010 18:17:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 33795-02-6 for ; Tue, 12 Oct 2010 21:17:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id CE39B1337C89 for ; Tue, 12 Oct 2010 18:16:20 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9CLGKFP007012 for ; Tue, 12 Oct 2010 17:16:20 -0400 (EDT) To: pgsql-performance@postgresql.org Subject: Re: read only transactions In-reply-to: <87zkuj884g.fsf@cbbrowne.afilias-int.info> References: <87zkuj884g.fsf@cbbrowne.afilias-int.info> Comments: In-reply-to Chris Browne message dated "Tue, 12 Oct 2010 16:32:31 -0400" Date: Tue, 12 Oct 2010 17:16:20 -0400 Message-ID: <7011.1286918180@sss.pgh.pa.us> From: Tom Lane 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: 201010/180 X-Sequence-Number: 40599 Chris Browne writes: > jnelson+pgsql@jamponi.net (Jon Nelson) writes: >> Are there any performance implications (benefits) to executing queries >> in a transaction where >> SET TRANSACTION READ ONLY; >> has been executed? > Directly? No. > Indirectly, well, a *leetle* bit... > Transactions done READ ONLY do not generate actual XIDs, which reduces > the amount of XID generation (pretty tautological!), which reduces the > need to do VACUUM to protect against XID wraparound. You're right that a read-only transaction doesn't generate an XID. But that is not a function of whether you do SET TRANSACTION READ ONLY; it's a function of refraining from attempting any database changes. The SET might be useful for clarifying and enforcing your intent, but it's not a performance boost to use it, versus just doing the read-only transaction without it. Also, I believe that SET TRANSACTION READ ONLY isn't a "hard" read only restriction anyway --- it'll still allow writes to temp tables for example, which will cause assignment of an XID. regards, tom lane