Re: CHAR(N) storage requirement

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: CHAR(N) storage requirement
Date: 2004-01-11 16:42:51
Message-ID: 16714.1073839371@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> 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.

Peter omitted one critical point that I think David hasn't absorbed
yet: char(N) measures N in characters, not bytes. When using a
multibyte encoding, N characters may require more than N bytes.
Only in single-byte encodings can you make any simple statements
about the number of bytes occupied by char(N). This is why the docs
are a bit vague.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Garamond 2004-01-11 16:51:17 Re: CHAR(N) storage requirement
Previous Message Peter Eisentraut 2004-01-11 16:02:00 Re: CHAR(N) storage requirement