Re: alter column type

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: alter column type
Date: 2015-06-05 18:55:25
Message-ID: 5571F09D.8060405@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Kehlet 2015-06-05 19:01:47 Re: [GENERAL] 9.4.1 -> 9.4.2 problem: could not access status of transaction 1
Previous Message Alvaro Herrera 2015-06-05 18:53:31 Re: 9.4.1 -> 9.4.2 problem: could not access status of transaction 1