Re: resizing a varchar column on 8.3.8

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: resizing a varchar column on 8.3.8
Date: 2011-01-29 01:48:58
Message-ID: ihvrma$cbe$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2011-01-27, Emi Lu <emilu(at)encs(dot)concordia(dot)ca> wrote:
> On 01/15/2011 04:22 PM, Jon Hoffman wrote:
>> Hi,
>>
>> I found a post with some instructions for resizing without locking up
>> the table, but would like to get some re-assurance that this is the best
>> way:
>>
>> http://sniptools.com/databases/resize-a-column-in-a-postgresql-table-without-changing-data
>>
>> How does that affect data storage and future updates on existing rows?

Under mvcc rows are discarded and replaced with new rows when you do updates.
Also postgres stores all strings types as text.

Varchar(n) is just text with an an added character length constraint.

There's no worry about old records not satisfying the new format, or
old records beeing too small for reuse.

there is rarely a good reason (other than conforming to standards?) to
prefer varchar over text when creating tables.

> I did not see any feedbacks about this topic.
>
> I need confirmation that it is safe to do this! Personally, I feel that
> it is specially useful when there are many view dependencies. Update
> from data dictionary, all views will be updated automatically, right?

The only problem I can see is aomeone in a (read commited) tranaction finding strings
in the table that are longer than they expected to find.

It feels safe to me. but if you want to sure, on a test database
insert some long strings, then make the limit shorter the existing
strings and see if it causes any problems.

--
⚂⚃ 100% natural

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Christensen 2011-01-29 01:50:45 Re: Error trying to install Ruby postgres gems on OS/X
Previous Message Thom Brown 2011-01-29 01:46:33 Re: Error trying to install Ruby postgres gems on OS/X