Re: alter column type - Mailing list pgsql-general

From John R Pierce
Subject Re: alter column type
Date
Msg-id 5571F09D.8060405@hogranch.com
Whole thread Raw
In response to Re: alter column type  (Ravi Krishna <sravikrishna3@gmail.com>)
Responses Re: alter column type
List pgsql-general
On 6/5/2015 11:37 AM, Ravi Krishna wrote:
> Why is PG even re-writing all rows when the data type is being changed
> from smaller (int) to larger (bigint) type, which automatically means
> existing data is safe. Like, changing from varchar(30) to varchar(50)
> should involve no rewrite of existing rows.


int to bigint requires storage change, as all bigints are 64 bit while
all ints are 32 bit.     it would be a MESS to try and keep track of a
table that has some int and some bigint storage of a given field.

now, varchar 30 to 50, that I can't answer, are you sure that does a
rewrite?   the storage is exactly the same for those.



--
john r pierce, recycling bits in santa cruz



pgsql-general by date:

Previous
From: Casey Deccio
Date:
Subject: Re: alter column type
Next
From: Steve Kehlet
Date:
Subject: Re: [HACKERS] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1