Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1C7229FB1D4 for ; Tue, 17 Oct 2006 16:04:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 79848-03 for ; Tue, 17 Oct 2006 16:04:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 8FEB99FB1CA for ; Tue, 17 Oct 2006 16:04:08 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 47D10308E2; Tue, 17 Oct 2006 21:04:07 +0200 (MET DST) From: Chris Browne X-Newsgroups: pgsql.performance Subject: Re: Optimization of this SQL sentence Date: Tue, 17 Oct 2006 14:09:41 -0400 Organization: cbbrowne Computing Inc Lines: 56 Message-ID: <60wt6y7r16.fsf@dba2.int.libertyrms.com> References: <45349CDF.3090002@rentalia.com> <4534A35E.9030909@rentalia.com> <181E6D21-8326-4ED6-A9AE-6F9917C1C319@purefiction.net> <200610171729.19596.mweilguni@sime.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.hub.org User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (linux) Cancel-Lock: sha1:padmXqdKsxA5UMvPahnuI686Vu0= To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.086 tagged_above=0 required=5 tests=AWL, INFO_TLD X-Spam-Level: * X-Archive-Number: 200610/328 X-Sequence-Number: 21457 mmoncure@gmail.com ("Merlin Moncure") writes: > On 10/17/06, Mario Weilguni wrote: >> Am Dienstag, 17. Oktober 2006 11:52 schrieb Alexander Staubo: >> > Lastly, note that in PostgreSQL these length declarations are not >> > necessary: >> > >> > 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. > > while you are correct, i think the spirit of the argument is wrong > becuase there is no constraint to be enforced in those fields. a > length constraint of n is only valid is n + 1 characters are an error > and should be rejected by the database. anything else is IMO bad > form. There are practial exceptions to this rule though, for example > client technology that might require a length. > > so, imo alexander is correct: > contacto varchar(255) > > ...is a false constraint, why exactly 255? is that were the dart landed? Yeah, 255 seems silly to me. If I'm going to be arbitrary, there are two better choices: 1. 80, because that's how many characters one can fit across a piece of paper whilst keeping things pretty readable; 2. 64, because that will fit on a screen, and leave some space for a field name/description. > specifically limiting text fields so users 'don't enter too much > data' is a manifestation c programmer's disease :) No, I can't agree. I'm pretty accustomed to languages that don't pinch you the ways C does, and I still dislike having over-wide columns because it makes it more difficult to generate readable reports. -- output = ("cbbrowne" "@" "linuxfinances.info") http://linuxdatabases.info/info/unix.html "Instant coffee is like pouring hot water over the cremated remains of a good friend."