From: Mark Kirkwood <markir@paradise.net.nz>
To: Mario Weilguni <mweilguni@sime.com>
Cc: pgsql-performance@postgresql.org, Alexander Staubo <alex@purefiction.net>
Cc: Ruben Rubio <ruben@rentalia.com>
Subject: Re: Optimization of this SQL sentence
Date: Wed, 18 Oct 2006 23:19:44 +1300
Message-ID: <4535FFC0.603@paradise.net.nz> (raw)
In-Reply-To: <200610171729.19596.mweilguni@sime.com>
References: <45349CDF.3090002@rentalia.com>
<4534A35E.9030909@rentalia.com>
<181E6D21-8326-4ED6-A9AE-6F9917C1C319@purefiction.net>
<200610171729.19596.mweilguni@sime.com>
Mario Weilguni wrote:
>>
>> Â Â contacto varchar(255),
>> Â Â fuente varchar(512),
>> Â Â prefijopais varchar(10)
>>
>> Instead, use:
>>
>> Â Â contacto text,
>> Â Â fuente text,
>> Â Â prefijopais text
>>
>> See the PostgreSQL manual for an explanation of varchar vs. text.
>
> Enforcing length constraints with varchar(xyz) is good database design, not a
> bad one. Using text everywhere might be tempting because it works, but it's
> not a good idea.
>
I've always used the rationale:
If you *know* that the data is length constrained, then it is ok to
reflect this in the domain you use - err, thats why they have length
limits! e.g. if you know that 'prefijopais' can *never* be > 10 chars in
length, then varchar(10) is a good choice.
If the data length is unknown or known to be unlimited, then reflect
that in the domain you use - e.g if 'fuente' or 'contacto' have no
reason to be constrained, then just use text.
best wishes
Mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: markir@paradise.net.nz, mweilguni@sime.com, alex@purefiction.net, ruben@rentalia.com
Subject: Re: Optimization of this SQL sentence
In-Reply-To: <4535FFC0.603@paradise.net.nz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox