Re: varchar lengths

From: Marcus Engene <mengpg2(at)engene(dot)se>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: varchar lengths
Date: 2010-09-21 11:54:13
Message-ID: 4C989CE5.3040605@engene.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/21/10 1:29 , Terry Lee Tucker wrote:
> On Tuesday, September 21, 2010 07:23:45 Massa, Harald Armin wrote:
>
>> I recommend to use TEXT as type for that kind of columns.
>> 99 out of 100 theories about "this value will never be longer then xx
>> characters" fail in the long run.
>>
>> And "text", limited only by PostgreSQLs limits, performs as good or
>> better then varchar(length_limit) The time of "we only can allow n
>> chars for first name" for performance reasons have gone by, together
>> with walkmen and VHS.
>>
>>
>> Harald
>>
> Also, if you are absolutely set on a constraint on the length of the text, you
> can use a trigger for this and when the constraint changes, and it will, you
> simply modify the trigger.
>
>
Thanks for your answers!

Richard was completely right of course. I hadn't actually tested this
since 8.0 but now it works splendidly. Apologies for the noise.

I do use text in several places but in some, where it's motivated, I
like to use constrained lengths. May it be tables that hold data that
goes to legacy systems, indexed columns (such as username) or the name
of a product.

Have a lovely tuesday everyone,
Marcus

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-09-21 11:54:36 Re: where does postgres keep the query result until it is returned?
Previous Message Terry Lee Tucker 2010-09-21 11:29:27 Re: varchar lengths