Re: enum for performance?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Whit Armstrong <armstrong.whit@xxxxxxxxx> 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

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux