0

Edited :

I need to remove foreign key constraints from some PostgreSQL tables. However, these tables are heavily used and contain a significant volume of data. Some are partitioned, while others are not.

When I try to alter the table to drop the foreign key, it causes a lock, which interrupts ongoing operations or is locked due to some write operation unless we schedule downtime.

Is there a way to remove foreign key constraints from a table in PostgreSQL without causing locks or impacting ongoing operations?

Any suggestions or best practices would be appreciated.

PS : I do think that without locks it could cause issues with data consistency, integrity, and concurrency control.

asked Jan 6 at 10:25
0

1 Answer 1

1

No, there is no way to remove a foreign key without placing a lock on the table. However, that lock will only be held for a very short time, so that shouldn't be a problem unless you always have long-running transactions that involve the table.

answered Jan 6 at 17:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.