Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1z7D-0002wm-EE for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2019 20:27:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i1z7C-0002am-4T for pgsql-general@arkaria.postgresql.org; Sun, 25 Aug 2019 20:27:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1z7B-0002ac-R9 for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2019 20:27:53 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i1z79-0002eR-P5 for pgsql-general@lists.postgresql.org; Sun, 25 Aug 2019 20:27:53 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x7PKRmmx001629; Sun, 25 Aug 2019 16:27:48 -0400 From: Tom Lane To: David Wall cc: pgsql-general@lists.postgresql.org Subject: Re: For SELECT statement (just a reading one, no 'FOR UPDATE'), is COMMIT or ROLLBACK preferred? In-reply-to: References: <3e16442c-a60a-679a-e72e-6d895552b6f8@computer.org> <3C2ED636-A81D-4BC4-92A1-38634F5DD5D2@gmail.com> Comments: In-reply-to David Wall message dated "Sun, 25 Aug 2019 13:12:30 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1627.1566764868.1@sss.pgh.pa.us> Date: Sun, 25 Aug 2019 16:27:48 -0400 Message-ID: <1628.1566764868@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Wall writes: > ... So we're trying to determine > if there's actually any difference between commit/rollback after SELECT > statements (with rows returned or not), a bit like if there's any > difference for an UPDATE statement that returns zero rows were updated. They're different code paths, but I'd expect any performance difference to be at the noise level; if nothing happened in the transaction then no WAL traffic will be emitted in either case. A more useful thing to think about, IMO, is this: if your app thinks that the statement had no side-effects but actually it did (maybe it called a volatile function that did something), would you want those effects to be persisted or not? regards, tom lane