Subject | Re: [firebird-support] What are the trade-offs of CHAR vs. VARCHAR? |
---|---|
Author | Mark Rotteveel |
Post date | 2019-11-13T11:10:04Z |
On 2019-11-12 23:06, Clyde Eisenbeis cte677@... [firebird-support]
wrote:
sizes of 4096, 8192, 16384, and - Firebird 4 - 32768 (earlier versions
also supported 1024 and 2048). Page size is unrelated to datatypes
sizes, except for things you want to index (because the page size does
restrict the key size of an index.
In any case, CHAR is limited to 32767 characters with a single byte
character set and 8191 characters with UTF8. VARCHAR is limited to 32765
characters (single byte) or 8191 characters with UTF8.
The only good reason to choose CHAR is for fixed width data, in all
other cases you should use VARCHAR. Storage-wise it doesn't really
matter in Firebird (although VARCHAR actually requires two bytes more
than CHAR in storage format), but VARCHAR is smailler in transmission in
the wire protocol. However, CHAR is padded with spaces, while VARCHAR is
not. For most uses of string data, VARCHAR is simply better.
Mark
wrote:
> As I understand, the FbConnection.CreateDatabase max pageSize forPage size is about the size of database pages, Firebird supports page
> VARCHAR is 8191. Does the page size change to less than 8191 if the
> VARCHAR is less?
>
> What is the max pageSize for CHAR?
sizes of 4096, 8192, 16384, and - Firebird 4 - 32768 (earlier versions
also supported 1024 and 2048). Page size is unrelated to datatypes
sizes, except for things you want to index (because the page size does
restrict the key size of an index.
In any case, CHAR is limited to 32767 characters with a single byte
character set and 8191 characters with UTF8. VARCHAR is limited to 32765
characters (single byte) or 8191 characters with UTF8.
The only good reason to choose CHAR is for fixed width data, in all
other cases you should use VARCHAR. Storage-wise it doesn't really
matter in Firebird (although VARCHAR actually requires two bytes more
than CHAR in storage format), but VARCHAR is smailler in transmission in
the wire protocol. However, CHAR is padded with spaces, while VARCHAR is
not. For most uses of string data, VARCHAR is simply better.
Mark