pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jan Wieck <JanWieck@Yahoo.com>
To: Scott Marlowe <smarlowe@qwest.net>
Cc: galvao@galvao.eti.br
Cc: pgsql-performance@postgresql.org
Subject: Re: NUMERIC x VARCHAR
Date: Wed, 11 Aug 2004 15:19:56 -0400
Message-ID: <411A715C.70808@Yahoo.com> (raw)
In-Reply-To: <1092205308.27166.358.camel@localhost.localdomain>
References: <4119B1C9.2010800@galvao.eti.br>
	<1092205308.27166.358.camel@localhost.localdomain>

On 8/11/2004 2:21 AM, Scott Marlowe wrote:

> 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.

They are stored as an array of signed small integers holding digits in 
base-10000, plus a precision, scale and sign. That's somewhat different 
from text strings, isn't it?


Jan

> 
> 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.
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html


-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



view thread (7+ messages)

Message-ID: <411A715C.70808@Yahoo.com>
Permalink:  ../411A715C.70808@Yahoo.com/
Also on:    postgresql.org/message-id/411A715C.70808@Yahoo.com

 · 

reply

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: JanWieck@Yahoo.com, smarlowe@qwest.net, galvao@galvao.eti.br
  Subject: Re: NUMERIC x VARCHAR
  In-Reply-To: <411A715C.70808@Yahoo.com>

* 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