Re: Faster data type for one-length values

Поиск
Список
Период
Сортировка
От André Volpato
Тема Re: Faster data type for one-length values
Дата
Msg-id 46545893.2030601@ecomtecnologia.com.br
обсуждение исходный текст
Ответ на Re: Faster data type for one-length values  (André Volpato<andre.volpato@ecomtecnologia.com.br>)
Ответы Re: Faster data type for one-length values  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
André Volpato escreveu:
> Tom Lane escreveu:
>> =?ISO-8859-1?Q?Andr=E9_Volpato?= <andre.volpato@ecomtecnologia.com.br> writes:
>>
>>> I need to store one-length values like '1', '2', '3' or '4' .
>>>
>>
>>
>>> Today, this field is indexed with btree and is of type smallint (int2).
>>> How much performance will be improved if I change it to "char" (1 byte
>>> length) ?
>>>
>>
>> The improvement will be zero.  Because of alignment restrictions, you
>> don't save any space from making an index entry smaller than 4 bytes.
>>
>> If you have several such fields adjacent in a table row, making them all
>> narrower can save space, but it doesn't help for standalone index
>> entries.
>>
>>             regards, tom lane
>>
Tom,

The ammount of space saved seems pretty clear to me.

What are you saying is that the index behaviour is the same, for all
types smaller than 4 bytes ?  For query performance, in a search is
based on that standalone indexed field, would be any difference using :

a. char(1) ;  b. int2;  c. "char"

Thanks again !

Andre Volpato


В списке pgsql-general по дате отправления:

Предыдущее
От: "Purusothaman A"
Дата:
Сообщение: Re: OIDs - file objects, are damaged by PostgreSQL.
Следующее
От: Rick Schumeyer
Дата:
Сообщение: Tsearch2: upgrading from postgres 8.1.x to 8.2.x