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

decimal(5) vs int8. Which more efficient.

From
Francisco Reyes
Date:
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?

Not finding much on the archives regarding this.



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

From
Thomas Lockhart
Date:
> 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.

                     - Thomas

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

From
Francisco Reyes
Date:
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.