Subject: Repeatable Read Isolation Level "transaction start time"

From: Wizard Brony <[email-masked]>
Date: Mon, 23 Sep 2024 11:15:20 -0400

https://www.postgresql.org/docs/16/transaction-iso.html#XACT-REPEATABLE-READ

The PostgreSQL documentation for the Repeatable Read Isolation Level states the following:

“UPDATE, DELETE, MERGE, SELECT FOR UPDATE, and SELECT FOR SHARE commands behave the same as SELECT in terms of searching for target rows: they will only find target rows that were committed as of the transaction start time.”

What is defined as the "transaction start time?" When I first read the statement, I interpreted it as the start of the transaction:

BEGIN;
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;

But in my testing, I find that according to that statement, the transaction start time is actually "the start of the first non-transaction-control statement in the transaction" (as mentioned earlier in the section). Is my conclusion correct, or am I misunderstanding the documentation?

---

From: Tom Lane <[email-masked]>
Date: Tue, 24 Sep 2024 10:28:46 -0400

> But in my testing, I find that according to that statement, the transaction start time is actually "the start of the first non-transaction-control statement in the transaction" (as mentioned earlie…

It's even looser than that, really: it's the first statement that
requires an MVCC snapshot.  From memory, LOCK TABLE is an important
exception --- you can acquire table locks before pinning down
a snapshot, and this is important in some scenarios.

			regards, tom lane