Re: decimal(5) vs int8. Which more efficient.

From: Francisco Reyes <lists(at)natserv(dot)com>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Cc: pgsql General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: decimal(5) vs int8. Which more efficient.
Date: 2002-03-09 15:54:20
Message-ID: 20020309105218.I30534-100000@zoraida.natserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 8 Mar 2002, Thomas Lockhart wrote:

> > What would be more efficient for storing a value that is 5 Bytes long?
> > decimal(5) or int8?
> > Does decimal(5) actually uses up only 5 bytes? Does that cause any
> > problems?
>
> int8 wins on all counts afaik. decimal() and numeric() store things as
> quasi-BCD and is less dense than a true binary storage type.

I decided to find a way to store the number, a key, in 4 bytes. Not what I
wanted, but... given the "issues" I read about int8 such as having
problems been recognized by the optimizer when doing searches.

The example on the docs is that something like:
select * from table where <int8> = ###

would not use the index. One would have to do:
select * from table where <int8> = '###'

Which is a pain.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-03-09 15:59:54 Re: RULE with conditional behaviour?
Previous Message Tom Lane 2002-03-09 15:37:58 Re: Fsync on/off For Various Filesystems/Platforms (Ending Note)