Updated on 2023-10-23 GMT+08:00

Concurrent Data Import and Queries

Transaction T1:

1
2
3
START TRANSACTION;
COPY test FROM '...';
COMMIT;

Transaction T2:

1
2
3
START TRANSACTION;
SELECT * FROM test;
COMMIT;

Scenario 1:

T1 is started but not committed. At this time, T2 is started. COPY of T1 and then SELECT of T2 starts, and both of them succeed. In this case, T2 cannot see the data added by COPY of T1.

Scenario 2:

  • READ COMMITTED level

    T1 is started but not committed. At this time, T2 is started. COPY of T1 is complete and T1 is committed. In this case, T2 can see the data added by COPY of T1.

  • REPEATABLE READ level

    T1 is started but not committed. At this time, T2 is started. COPY of T1 is complete and T1 is committed. In this case, T2 cannot see the data added by COPY of T1.