Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 173009FA154 for ; Tue, 17 Oct 2006 13:51:25 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 71171-06 for ; Tue, 17 Oct 2006 16:51:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.224]) by postgresql.org (Postfix) with ESMTP id 7FA379F93A0 for ; Tue, 17 Oct 2006 13:51:21 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id i21so258957wra for ; Tue, 17 Oct 2006 09:51:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ErBNw9WqDkFXZJGQBDT6ISKdzpNoCb1F8PvlNEUt5QN28j/H0vMWlB4X/cx/QMTIbRVa/+EhYSAL4Gom82UEpy1PRAgdH3hHkuogL/3HXwE4hyaVB576i7LfzCCd9ogIp2iHuAK97YwdlJv7hr+OJJL9zUD49rM3r0gZIh2QojQ= Received: by 10.78.151.15 with SMTP id y15mr9658143hud; Tue, 17 Oct 2006 09:51:19 -0700 (PDT) Received: by 10.78.35.18 with HTTP; Tue, 17 Oct 2006 09:51:19 -0700 (PDT) Message-ID: Date: Tue, 17 Oct 2006 12:51:19 -0400 From: "Merlin Moncure" To: "Mario Weilguni" Subject: Re: Optimization of this SQL sentence Cc: pgsql-performance@postgresql.org, "Alexander Staubo" , "Ruben Rubio" In-Reply-To: <200610171729.19596.mweilguni@sime.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45349CDF.3090002@rentalia.com> <4534A35E.9030909@rentalia.com> <181E6D21-8326-4ED6-A9AE-6F9917C1C319@purefiction.net> <200610171729.19596.mweilguni@sime.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.199 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, SPF_PASS X-Spam-Level: X-Archive-Number: 200610/327 X-Sequence-Number: 21456 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? specifically limiting text fields so users 'don't enter too much data' is a manifestation c programmer's disease :) note I am not picking on the OP here, just weighing in on the constraint argument. merlin