Re: Datatype sizes; a space and speed issue?
От | Stephan Szabo |
---|---|
Тема | Re: Datatype sizes; a space and speed issue? |
Дата | |
Msg-id | 20040622212727.T37757@megazone.bigpanda.com обсуждение исходный текст |
Ответ на | Re: Datatype sizes; a space and speed issue? (Joel Matthew <rees@ddcom.co.jp>) |
Ответы |
Re: Datatype sizes; a space and speed issue?
|
Список | pgsql-general |
On Wed, 23 Jun 2004, Joel Matthew wrote: > > What effect is there if I specify "TEXT" instead of > > say "VARCHAR(255)"? > > Well, theoretically, in the latter case, the database will allocate 256 > (257? 259?) bytes for that field in the record itself. That is, that > field will consume 256 bytes for each record stored. Both text and varchar are stored in PostgreSQL as length + string so varchar(256) doesn't not require storage of the unused bytes. char space pads so it's the oddball (requiring length + padded string). > > How much benefit is there do being more aggresive > > and say cutting it in half again by using "VARCHAR(128)"? > > Well, that would reduce the storage requirements for that field by half. > It might also prevent you from storing necessary information. That's > easily 128 characters if you're only using US-ASCII in UTF-8, but it's > only 32 characters of Unicode in UTF-32, and it could be anywhere > between 128 and 32 in Unicode UTF-8. Making a good prediction about the > tradeoff is one of the things a database engineer is paid for. varchar lengths should be in characters not bytes, so that should be 128 characters in any of the encodings, but the actual number of bytes that those 128 characters can take up may vary.
В списке pgsql-general по дате отправления: