Re: enum for performance?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: enum for performance?
Дата
Msg-id 5090.1245276728@sss.pgh.pa.us
обсуждение исходный текст
Ответ на enum for performance?  (Whit Armstrong <armstrong.whit@gmail.com>)
Список pgsql-performance
Whit Armstrong <armstrong.whit@gmail.com> 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
considerations.

            regards, tom lane

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

Предыдущее
От: Whit Armstrong
Дата:
Сообщение: enum for performance?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: very slow selects on a small table