patternsqlMajor
PostgreSQL: How does COPY FROM behave inside a transaction?
Viewed 0 times
postgresqlbehavetransactiondoeshowinsidefromcopy
Problem
I have an 8-million-line CSV file I need to import into a table. This import will currently take place within a transaction.
Does COPY FROM create a subtransaction? Will a failure roll back the parent transaction, or leave it alone?
Does COPY FROM create a subtransaction? Will a failure roll back the parent transaction, or leave it alone?
Solution
Does COPY FROM create a subtransaction?
No. It creates a single transaction if not run in a transaction; otherwise it will use the current transaction.
Will a failure roll back the parent transaction, or leave it alone?
It will roll back the parent transaction.
If you want a subtransaction, start one explicitly before the
There is no way to cause
No. It creates a single transaction if not run in a transaction; otherwise it will use the current transaction.
Will a failure roll back the parent transaction, or leave it alone?
It will roll back the parent transaction.
If you want a subtransaction, start one explicitly before the
COPY FROM.There is no way to cause
COPY FROM to ignore errors and continue. Any error causes the whole COPY to fail.Context
StackExchange Database Administrators Q#184032, answer score: 20
Revisions (0)
No revisions yet.