Re: Alter table fast

2025-01-27 Thread Gus Spier
I don't think I qualify as an expert, but I can nominate a course of action for you to consider. Rather than convert an existing column from one data type to another, might it not be easier to simply recreate the table with the correct data type. There are caveats! You have to consider any refer

Re: Alter table fast

2025-01-12 Thread Marco Torres
This is the right approach, Peter J. Holzer, from a well season DBA perspective "ALTER TABLE working_table ADD COLUMN B INTEGER ; UPDATE working_table SET B = A;" Bare in mind the indexes or existing references to an from other tables and act accordingly-- define the new and drop the old. Good lu

Re: Alter table fast

2025-01-12 Thread Peter J. Holzer
On 2025-01-09 20:52:27 +0100, sham...@gmx.net wrote: > Am 09.01.25 um 20:17 schrieb veem v: > > > Out of curiosity, why NUMERIC(15,0) instead of BIGINT? > > > > It's for aligning the database column types to the data model and > > it's happening across all the upstream downstream systems. I was >

Re: Alter table fast

2025-01-09 Thread shammat
Am 09.01.25 um 20:17 schrieb veem v: Out of curiosity, why NUMERIC(15,0) instead of BIGINT? It's for aligning the database column types to the data model and it's happening across all the upstream downstream systems. I was thinking if this can be made faster with the single line alter statemen

Re: Alter table fast

2025-01-09 Thread veem v
On Thu, 9 Jan 2025 at 21:57, Ron Johnson wrote: > On Thu, Jan 9, 2025 at 11:25 AM veem v wrote: > >> Hello, >> It's postgres version 16.1, we want to convert an existing column data >> type from integer to numeric and it's taking a long time. The size of the >> table is ~50GB and the table has ~

Re: Alter table fast

2025-01-09 Thread Ron Johnson
On Thu, Jan 9, 2025 at 11:25 AM veem v wrote: > Hello, > It's postgres version 16.1, we want to convert an existing column data > type from integer to numeric and it's taking a long time. The size of the > table is ~50GB and the table has ~150million rows in it and it's not > partitioned. We trie

Alter table fast

2025-01-09 Thread veem v
Hello, It's postgres version 16.1, we want to convert an existing column data type from integer to numeric and it's taking a long time. The size of the table is ~50GB and the table has ~150million rows in it and it's not partitioned. We tried running the direct alter and it's going beyond hours, so