char or int vs varchar
От | Keith Worthington |
---|---|
Тема | char or int vs varchar |
Дата | |
Msg-id | 20050422200053.M57618@narrowpathinc.com обсуждение исходный текст |
Ответы |
Re: char or int vs varchar
|
Список | pgsql-novice |
Hi All, I am building a new table and I would appreciate your thoughts on a data storage and performance question I need to store a (at the moment) tristate variable. Now this could be done as a char "L", "S", "T" as an int2 1, 2, 3 or as a varchar(8) "loose", "standard", "tight" among possibly other ways. For absolute storage minimum char would be the best at 1 byte but the documentation indicates that it is an internal type so I do not know whether or not I can really use it. If not then character(1) would have to be used and it looks like that would use up 5 bytes. For readability varchar(8) obviously wins. The documentation assures me that other than using 12 bytes there is "no performance differences between these three types". Finally there is the smallint at 2 bytes. Almost the smallest in terms of disk usage I wonder how it will affect performance since in most cases I would probably have to use a CASE statement to convert to something a human would intuitively understand. Kind Regards, Keith
В списке pgsql-novice по дате отправления: