Re: Single Byte values
От | Nigel J. Andrews |
---|---|
Тема | Re: Single Byte values |
Дата | |
Msg-id | Pine.LNX.4.21.0304032156210.12600-100000@ponder.fairway2k.co.uk обсуждение исходный текст |
Ответ на | Single Byte values (Jason Hihn <jhihn@paytimepayroll.com>) |
Ответы |
Re: Single Byte values
|
Список | pgsql-general |
On Thu, 3 Apr 2003, Jason Hihn wrote: > As someone pointed out, CHAR(1) costs 5 bytes. Is there a better way to > store it? I can see one or three bytes as being bad (byte-alignment issues > and speed) Two could be ok, but at the very least 4 should be the max for > char(1). > > Two is ok, once you consider multi-bytes strings (unicode) > Three is right out - > Four bytes could store two multibyte, two single byte (cast as 2 byte for > unicode) or four single byte characters. > > But in returning to my question, what should I be using for char(1) to > char(4) storage? > > Thanks again! I say you should use char(1) or whatever if that's what your requirement is. I'm not sure on the storage details but I doubt using text type will save anything. I also suspect the 5 byte cost isn't just the data but column overhead as well. I think the person saying not to use it is really saying why limit yourself to 1 character when for similar cost you can get 1 character _and_ the ability to get more than 1 character. However, this comes back to my point, if 1 character is what you need then use a char(1). Unfortunately, the example that jumped to my mind of vehicle registration year tags doesn't work, somewhere along the line that part of registration numbers became 2 letters instead of 1, which would really come back and haunt you if you'd done your database to be char(1) and had been amassing data for years before the change. -- Nigel J. Andrews
В списке pgsql-general по дате отправления: