From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Rob Gansevles <rgansevles(at)gmail(dot)com> |
Subject: | Re: Maximum size for char or varchar with limit |
Date: | 2010-12-08 15:19:27 |
Message-ID: | 201012080719.28136.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday 08 December 2010 7:06:07 am Rob Gansevles wrote:
> Adrian,
>
> Thanks for the reply, but this refers to max row or field size, it
> does not tell me where the max varchar limit of 10485760 comes from
> and if this is fixed or whether it depends on something else
>
> Has anyone some info on this?
>
> Rob
In varchar(n) the n is length of character not bytes. The best description of
what that means is from section 8.3
"The storage requirement for a short string (up to 126 bytes) is 1 byte plus the
actual string, which includes the space padding in the case of character.
Longer strings have 4 bytes of overhead instead of 1. Long strings are
compressed by the system automatically, so the physical requirement on disk
might be less. Very long values are also stored in background tables so that
they do not interfere with rapid access to shorter column values. In any case,
the longest possible character string that can be stored is about 1 GB. (The
maximum value that will be allowed for n in the data type declaration is less
than that. It wouldn't be useful to change this because with multibyte
character encodings the number of characters and bytes can be quite different.
If you desire to store long strings with no specific upper limit, use text or
character varying without a length specifier, rather than making up an
arbitrary length limit.) "
So the answer is, it depends on your encoding.
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2010-12-08 15:32:02 | Re: Asynchronous query execution |
Previous Message | Rob Gansevles | 2010-12-08 15:06:07 | Re: Maximum size for char or varchar with limit |