Skip to content
Advertisement

Create a Primary Key on a large table (6Million records) without locking the table in PostgreSQL

I want to create a Primary Key on a table with 6 Million records, but when I execute this:

It’s locking my table and alter table does not finish executing…

Advertisement

Answer

Try to do it in two steps:

It will still take a long time (even longer), but the table will not be locked.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement