X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2ECAE14B286F for ; Wed, 11 Aug 2004 03:20:41 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52533-08 for ; Wed, 11 Aug 2004 06:20:30 +0000 (GMT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by svr1.postgresql.org (Postfix) with SMTP id AC26D14B286A for ; Wed, 11 Aug 2004 03:20:26 -0300 (ADT) Received: (qmail 2404 invoked by uid 0); 11 Aug 2004 06:20:27 -0000 Received: from unknown (63.231.195.5) by mpls-qmqp-01.inet.qwest.net with QMQP; 11 Aug 2004 06:20:27 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-05.inet.qwest.net with SMTP; 11 Aug 2004 06:20:26 -0000 Date: Wed, 11 Aug 2004 00:21:48 -0600 Message-Id: <1092205308.27166.358.camel@localhost.localdomain> From: "Scott Marlowe" To: galvao@galvao.eti.br Cc: pgsql-performance@postgresql.org Subject: Re: NUMERIC x VARCHAR In-Reply-To: <4119B1C9.2010800@galvao.eti.br> References: <4119B1C9.2010800@galvao.eti.br> Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200408/148 X-Sequence-Number: 7784 On Tue, 2004-08-10 at 23:42, Er Galvão Abbott wrote: > Greetings. > > I have a question regarding performance of certain datatypes: > > I have a field where I will store my clients phone numbers. I know > that this field will never exceed 15 characters, and I will store only > numbers here (no dashes, dots, etc...), so I was wondering: > > Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any > storage differences between them? Since numerics are stored as text strings, the storage would be similar. Numerics, however, may be slower since they have more constraints built in. If you throw a check constraint on the varchar(15) then it will likely be about the same speed for updating. text type with a check contraint it what i'd use. That way if you want to change it at a later date you just drop and recreate your constraint.