decimal(5) vs int8. Which more efficient.

Поиск
Список
Период
Сортировка
Искать

decimal(5) vs int8. Which more efficient.

От:
Francisco 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.


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

От:
Thomas Lockhart <lockhart@fourpalms.org>
Дата:
> 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.

От:
Francisco Reyes <lists@natserv.com>
Дата:
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  = ###

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

Which is a pain.

FAQ