Re: Datatype sizes; a space and speed issue?
От | Madison Kelly |
---|---|
Тема | Re: Datatype sizes; a space and speed issue? |
Дата | |
Msg-id | 40D916FF.9090902@alteeve.com обсуждение исходный текст |
Ответ на | Re: Datatype sizes; a space and speed issue? (Alvaro Herrera <alvherre@dcc.uchile.cl>) |
Список | pgsql-general |
Alvaro Herrera wrote: > On Wed, Jun 23, 2004 at 01:15:23PM +0900, 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. > > > Nope. Actually, in both cases the length will be stored first (4 bytes) > and the actual content following it, using the indicated amount of > bytes. There's absolutely no difference in storage. > > A varchar(256) field will allow you to store a text not with 256 bytes > max, but 256 _chars_ max. Think multibyte encodings such as utf8 -- the > varchar(256) can take anything from 4 + 1 bytes (a single byte string) to > 4 + 256 * max_bytes_per_char. > > > The difference you cite is for char(N) fields, which are always padded > with blanks to fill the N chars. Thank you everyone for enswering, that actually clears up a lot. Thank you too for not flaming this n00b! Madison
В списке pgsql-general по дате отправления: