Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1staCq-00HYSA-S4 for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2024 22:09:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1staCp-00FCdJ-KI for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2024 22:09:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1staCp-00FCdB-A1 for pgsql-general@lists.postgresql.org; Wed, 25 Sep 2024 22:09:55 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1staCm-0013ff-Nl for pgsql-general@lists.postgresql.org; Wed, 25 Sep 2024 22:09:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 48PM9iEp152526; Wed, 25 Sep 2024 18:09:44 -0400 From: Tom Lane To: "Peter J. Holzer" cc: pgsql-general@lists.postgresql.org Subject: Re: Repeatable Read Isolation Level "transaction start time" In-reply-to: <20240925215554.gfg24h5sp5aqesxv@hjp.at> References: <9CEBFAC7-4372-4FF0-8124-FFFE834B03C6@gmail.com> <3346993.1727188126@sss.pgh.pa.us> <28109.1727286817@sss.pgh.pa.us> <20240925215554.gfg24h5sp5aqesxv@hjp.at> Comments: In-reply-to "Peter J. Holzer" message dated "Wed, 25 Sep 2024 23:55:54 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <152524.1727302184.1@sss.pgh.pa.us> Date: Wed, 25 Sep 2024 18:09:44 -0400 Message-ID: <152525.1727302184@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "Peter J. Holzer" writes: > On 2024-09-25 13:53:30 -0700, Christophe Pettus wrote: >> This might well be a failure of imagination on my part, but when would >> it pragmatically matter that the snapshot is taken at the first >> statement as opposed to at BEGIN? > It may make a difference if you're comparing timestamps. > For example, if you're using isolation level REPEATABLE READ and > (mistakenly) assume that the snapshot is taken at BEGIN, you would > expect any transaction_timestamp() written by a different transaction > and readable by this transaction to be earlier than the > transaction_timestamp() of this transaction. > But that's wrong because the other transaction could have happened > entirely in the time between your BEGIN and the statement which actually > triggers the snapshot. I don't find that hugely compelling, because there's always going to be some skew between the time we read the clock for the timestamp and the time we obtain the snapshot. Admittedly, that would normally not be a very long interval if BEGIN did both things ... but on a busy system you could lose the CPU for awhile in between. regards, tom lane