Given this scenario:
TIME TRANSACTION 1 TRANSACTION 2
1sec BEGIN
2sec INSERT RECORDS INTO T1
3sec (doing other things) BEGIN
4sec (doing other things) (doing other things)
5sec COMMIT (doing other things)
6sec SELECT * FROM T1 <<- GETS ROWS INSERTED BY T1
According to postgres docs:
Also note that two successive SELECT commands can see different data, even though they are within a single transaction, if other transactions commit changes during execution of the first SELECT
The question is: how to avoid SELECT
from getting rows committed between the beginning of transaction and the beginning of query.