Re: User-Defined Types - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: User-Defined Types
Date
Msg-id 22C28D3C-52D8-40CF-8A46-D48FAE69940C@seespotcode.net
Whole thread Raw
In response to User-Defined Types  ("David F. Johnson" <dfjohnson@cabaret.com>)
List pgsql-general
On Jul 5, 2007, at 15:53 , David F. Johnson wrote:

> During the development of a database often there is a need to change a
> field's declaration from, say, VARCHAR(32) to, say, VARCHAR(64).

> Is there a simple way to make a user-defined type that is a specific
> declaration of a built-in type (like VARCHAR(##)) without having to
> implement the type's support functions?

In PostgreSQL there's no performance advantage to limiting a varchar.
I'd recommend making all of your references to any varchar columns
not include a limit (i.e., just text or varchar), and perhaps setting
the referenced column as text with a length check constraint if one
is needed to satisfy some business rule. Then you can easily alter
the allowed length by altering the check constraint. (Similarly you
could use varchar(n) on the referenced column as well, and then just
ALTER TABLE ALTER TYPE instead of altering the check constraint. I
don't know if one has a performance advantage in checking the length
of the value.)


Michael Glaesemann
grzm seespotcode net



pgsql-general by date:

Previous
From: "Tim Olsen"
Date:
Subject: Re: dropdb ; createdb equivalent without createdb permission?
Next
From: "Alexander Staubo"
Date:
Subject: Re: Performance Question - Table Row Size