Re: ALTER TEXT field to VARCHAR(1024)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ALTER TEXT field to VARCHAR(1024)
Date: 2014-09-22 17:22:25
Message-ID: 17116.1411406545@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> In the end the two questions are:
> 1) does adding a length restriction cause a table rewrite?

Yes. In principle the restriction could be checked with just a scan,
not a rewrite, but ALTER TABLE doesn't currently understand that --- and
in any case a scan would still be potentially a long time.

> 2) what level of locking occurs while the length check is resolving?

AccessExclusiveLock. This would be necessary in any case for a data type
change.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Luke Coldiron 2014-09-22 18:17:05 large table
Previous Message David G Johnston 2014-09-22 17:11:18 Re: ALTER TEXT field to VARCHAR(1024)