1
votes

Imagine I have two transactions

T1 - a heavy data crunching job writing to a table say Table1 in READ_COMMITTED isolation level. T2 - a transaction which reads data from Table1 with SERIALIZABLE isolation level.

Table1 Schema

autoincrement_id(INT) data(varchar)

T1 (READ_COMMITTED)

INSERT INTO Table1.. INSERT INTO Table1.. INSERT INTO Table1.. INSERT INTO Table1..

T2 (SERIALIZABLE)

SELECT * FROM Table1 WHERE autoincrement_id > x; --DO SOMETHING

If T2 starts before T1, it would virtually stop T1 (correct?)

But if T1 starts before T2 and is still in progress during T2, will T2 read data that was inserted but not commited by T1?

1

1 Answers

2
votes

If T2 starts before T1, it would virtually stop T1 (correct?)

Yes, correct!

But if T1 starts before T2 and is still in progress during T2, will T2 read data that was inserted but not commited by T1?

No, T1 would virually stop T2 then. So T2 waits for T1 either to be commited or to be rolled back (at least in theory...).