| From: | Mohamed Wael Khobalatte <mkhobalatte(at)grubhub(dot)com> |
|---|---|
| To: | Guillaume Lelarge <guillaume(at)lelarge(dot)info> |
| Cc: | Torge Kummerow <tk(at)panaccess(dot)com>, pgsql-sql(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Non blocking type change for primary column |
| Date: | 2021-01-16 05:18:39 |
| Message-ID: | CABZeWdxsitbHGhj2PahAc64HnB-BD7i3njok8gwh7FV_4Bft6A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Roberto Médola | 2021-01-19 13:02:48 | Bring to dead tuples to alive |
| Previous Message | Guillaume Lelarge | 2021-01-15 09:42:51 | Re: Non blocking type change for primary column |