Re: enum for performance?

От: Tom Lane
Тема: Re: enum for performance?
Дата: ,
(см: обсуждение, исходный текст)
Ответ на: enum for performance?  (Whit Armstrong)
Список: pgsql-performance

Whit Armstrong <> writes:
> I have a column which only has six states or values.
> Is there a size advantage to using an enum for this data type?
> Currently I have it defined as a character(1).

Nope.  enums are always 4 bytes.  char(1) is going to take 2 bytes
(assuming those six values are simple ASCII characters), at least
as of PG 8.3 or later.

Depending on what the adjacent columns are, the enum might not actually
cost you anything --- the difference might well disappear into alignment
padding anyway.  But it's not going to save.

Another possibility is to look at the "char" (not char) type, which also
stores single ASCII-only characters.  That's just one byte.  But again,
it might well not save you anything, depending on alignment

            regards, tom lane

В списке pgsql-performance по дате сообщения:

От: Tom Lane
Сообщение: Re: very slow selects on a small table
От: Alberto Dalmaso
Сообщение: Re: performance with query