Re: Non blocking type change for primary column - Mailing list pgsql-sql

From Mohamed Wael Khobalatte
Subject Re: Non blocking type change for primary column
Date
Msg-id CABZeWdxsitbHGhj2PahAc64HnB-BD7i3njok8gwh7FV_4Bft6A@mail.gmail.com
Whole thread Raw
In response to Re: Non blocking type change for primary column  (Guillaume Lelarge <guillaume@lelarge.info>)
List pgsql-sql
1. adding a new nullable column of type bigint.
2. copying the primary key into this field in small batches
3. Once done. rename the primary column and new column, to swap them
4. attach the sequence to the new column and deattach it from the old column
5. Make new column NON NULL (Not sure if this will block)
6. Remove primary key from old column, make new column to be the primary
key (I fear this will block to create the index, but I guess not nearly
as long as ALTER COLUMN type)
7. Delete old column.

This could be prevented, if this would be done in a non blocking way by
the database system itself, so I hope this is already implemented or at
least on the roadmap.
Any thoughts?

Hye Torge,

I was recently involved with such a change. See this thread[1]  for discussion. In particular, it touches on point 5, where you ask what's blocking. Hope it helps. 

[1] https://www.postgresql.org/message-id/flat/CABZeWdybDVTgCQFZf0jDtj0p4yLxNrYd8aw61iFxY-Xt%2BfqPkw%40mail.gmail.com

pgsql-sql by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Non blocking type change for primary column
Next
From: Roberto Médola
Date:
Subject: Bring to dead tuples to alive