From: | Madison Kelly <linux(at)alteeve(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Datatype sizes; a space and speed issue? |
Date: | 2004-06-23 05:37:03 |
Message-ID: | 40D916FF.9090902@alteeve.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Matthew | 2004-06-23 05:43:06 | Re: Datatype sizes; a space and speed issue? |
Previous Message | Tom Lane | 2004-06-23 05:11:50 | Re: Datatype sizes; a space and speed issue? |