datatype advice numeric vs. varchar

From: Gene <genekhart(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: datatype advice numeric vs. varchar
Date: 2007-01-18 06:15:02
Message-ID: 430d92a20701172215o4dbd644dh4418fb3346a85906@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm working on a voicemail application which involves storing phone
numbers and other types that have long sequences of digits [0-9]. I
need to be able to do pattern matching using LIKE and map the fields
back to java String objects. I was thinking maybe it would be more
efficient to use the numeric(x,0) type instead of a varchar since it
could use less space on disk.

My calculations for disk space based off some information i found
online are ( 8 + ( 2 bytes for every four digits) ) for numeric and (
4 + number of chars ) for a utf8 varchar datatype. Are these
calculations still valid and has anyone tried using numeric for this
purpose or is this really stupid?

Thanks for any hints!
Gene

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2007-01-18 06:15:10 Re: FATAL: invalid frontend message type 47 server closed the connection unexpectedly
Previous Message Adam Rich 2007-01-18 05:57:41 Re: How I can read-back a serial value just inserted?