Re: datatype advice numeric vs. varchar

From: Gene <genekhart(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, gene(at)sotech(dot)us, pgsql-general(at)postgresql(dot)org
Subject: Re: datatype advice numeric vs. varchar
Date: 2007-01-18 06:25:12
Message-ID: 430d92a20701172225w53d1b338va1dfd93ba7125441@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

you're probably right, actually using LIKE with numeric works fine but
of course i will have to contend with things like truncating zeros to
the left etc... are there any advantages to using ascii encoding as
far as performance of LIKE, REGEXES, INDEXES etc versus using UTF8?

thanks, gene

On 1/18/07, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> On Thu, Jan 18, 2007 at 01:15:02AM -0500, Gene wrote:
> > 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.
>
> Your calculations are reasonable, but if you do it as numeric you're
> going to be fighting the system the whole way. Numerics are treated as
> numbers and things like LIKE don't work on them. When you select them,
> java is likely to convert them to numbers there too.
>
> Is this not a case of premature optimisation?
>
> Have a nice day,
> --
> Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> > From each according to his ability. To each according to his ability to litigate.
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFFrxFpIB7bNG8LQkwRAvMbAKCJ/1OeO5U7sk0QGjl9YBia4sfRjwCfSFWy
> TK5gVC8ybtnH2Xtdco6SGqA=
> =pUUw
> -----END PGP SIGNATURE-----
>
>
>

--
Gene Hart
cell: 443-604-2679

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darmawan Sugiarto 2007-01-18 06:32:51 libpq/libpq-fs.h
Previous Message Michael Glaesemann 2007-01-18 06:22:24 Re: datatype advice numeric vs. varchar