I have a Java application that reads from a group of tables, process data and then inserts the processed data into one table. The data volume is really large and multi threading is inevitable. The problem is happening when multiple threads attempt to insert at the same time, which causes a write hold and an insert hold. After that all the threads wait for the table to be available until the connection times out.
The records being inserted do not have any foreign keys pointing to any table
The records being inserted are completely independent from each other
The table does not have an incremental ID of any sort
No other application is using any of the tables involved in this application
I am using Java prepared statement to do the insert. Each calls an insert method which opens a connection for each thread separately.
Is there anything I'm doing wrong or is it a compatibility issue with Redshift?
COPY and INSERT operations are pure write ... COPY and INSERT operations against the same table are held in a wait state until the lock is released, then they proceed as normal.See docs.aws.amazon.com/es_es/redshift/latest/dg/… - Federico Sierrajava.sql.Connectionobject. - Med Zamrik