Re: Updating pg_attribute to change field's data type from integer to bigint on very large table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Adams <jeff(dot)adams(at)noaa(dot)gov>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Updating pg_attribute to change field's data type from integer to bigint on very large table
Date: 2012-04-13 15:03:12
Message-ID: 23940.1334329392@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Adams <jeff(dot)adams(at)noaa(dot)gov> writes:
> I have a very large table (approximately 1 billion records). I need to
> change a field's data type from integer to bigint. I started up an ALTER
> TABLE approach yesterday and it is still running (trying to rewrite the
> whole table?). I remember seeing mention of being able to do this in the
> pg_attribute table. Has anybody ever used the latter approach. If so,
> instructions would be greatly appreciated. Thanks...

No, that is an actual on-disk change (making the field physically
wider), so it's going to cost ya. There are some cases where the
on-disk representation doesn't change and so a catalog update isn't
needed, but int4->int8 isn't one of them.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-04-13 15:27:28 Re: Updating pg_attribute to change field's data type from integer to bigint on very large table
Previous Message Albe Laurenz 2012-04-13 14:35:40 Re: aggregate arrays