Re: Adding New Column with default value.
От | Ed Sabol |
---|---|
Тема | Re: Adding New Column with default value. |
Дата | |
Msg-id | 17230BE4-D6C6-422F-8537-6E2381B30AD8@gmail.com обсуждение исходный текст |
Ответ на | Adding New Column with default value. (Gambhir Singh <gambhir.singh05@gmail.com>) |
Ответы |
Re: Adding New Column with default value.
|
Список | pgsql-admin |
On Apr 28, 2025, at 1:24 PM, Gambhir Singh <gambhir.singh05@gmail.com> wrote: > Row Count - 50 Billion I've never dealt with a table that huge personally, but my concern would be that ALTER TABLE will lock the table for a verylong time. Is this in a production environment with active usage of this table? Just SELECTs or are we talking UPDATEsand INSERTs as well? If so, you might need to do something more complicated than just ALTER TABLE. If you have enough disk space in the storage area for this database to have two identical copies of this 50 billion row table(with indexes!), you could make a copy of the table and either ALTER that copy or add the new column at the same timeas making the copy and then, in a single transaction, rename the two tables to swap them. If you do it this way, thenew table will replace the old table seamlessly without interrupting usage of the table. Somewhere in there, you mightneed to re-sync the two tables to make sure any rows that got inserted or updated while you were making the copy areincorporated into the new version of the table as well. Just some initial thoughts on how I would accomplish this and things I would consider when deciding how to do it. Good luck, Ed
В списке pgsql-admin по дате отправления: