I have a lambda code that fires some insert queries to the same Table concurrently through redshift data api.
1. Insert into Table ( select <some analytical logic> from someTable_1) 2. Insert into Table ( select <some analytical logic> from someTable_2) 3. Insert into Table ( select <some analytical logic> from someTable_n)
Considering such queries will be fired concurrently, does Redshift apply a lock to the Table for each insert? Or does it allow parallel insert queries in the same table? I’m asking because postgres allows concurrent inserts.
https://www.postgresql.org/files/developer/concurrency.pdf
Advertisement
Answer
Based on the discussion in comments, one can conclude that concurrent inserts into the same table in Redshift are blocking in nature as opposed to postgres. Refer to the docs:- https://docs.aws.amazon.com/redshift/latest/dg/r_Serializable_isolation_example.html
Edit:-
FYI if you are thinking what is the exact information to look for in the above mentioned docs, I am directly pasting it below:-
Concurrent COPY operations into the same table Transaction 1 copies rows into the LISTING table: begin; copy listing from ...; end; Transaction 2 starts concurrently in a separate session and attempts to copy more rows into the LISTING table. Transaction 2 must wait until transaction 1 releases the write lock on the LISTING table, then it can proceed. begin; [waits] copy listing from ; end; The same behavior would occur if one or both transactions contained an INSERT command instead of a COPY command.