Re: CHAR(N) storage requirement - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: CHAR(N) storage requirement
Date
Msg-id 200401111702.00538.peter_e@gmx.net
Whole thread Raw
In response to CHAR(N) storage requirement  (David Garamond <lists@zara.6.isreserved.com>)
Responses Re: CHAR(N) storage requirement  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: CHAR(N) storage requirement  (David Garamond <lists@zara.6.isreserved.com>)
List pgsql-general
David Garamond wrote:
> Is it the 4+N (aka. same as VARCHAR(n)) or is it N? Sorry, it was
> 100% not clear for me after reading the docs, though the docs imply
> the first: "The storage requirement for data of these types is 4
> bytes plus the actual string, and in case of character plus the
> padding."

Storing varchar(n) takes 4 bytes plus as many bytes as are required to
store the actual string.  This may be more or less then "n".

Storing char(n) takes 4 bytes plus as many bytes are are required to
store the actual string, plus n - length(value) bytes for padding
spaces.  This is at least "n" bytes.


pgsql-general by date:

Previous
From: David Garamond
Date:
Subject: Drawbacks of using BYTEA for PK?
Next
From: Tom Lane
Date:
Subject: Re: CHAR(N) storage requirement