decimal(5) vs int8. Which more efficient.

Started by Francisco Reyesabout 24 years ago3 messagesgeneral
Jump to latest
#1Francisco Reyes
lists@natserv.com

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.

#2Thomas Lockhart
lockhart@fourpalms.org
In reply to: Francisco Reyes (#1)
Re: decimal(5) vs int8. Which more efficient.

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

#3Francisco Reyes
lists@natserv.com
In reply to: Thomas Lockhart (#2)
Re: decimal(5) vs int8. Which more efficient.

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.