|
Home > Archive > PostgreSQL Discussion > August 2005 > About column type to "varchar(1)" or "char(1)"
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
About column type to "varchar(1)" or "char(1)"
|
|
| Emi Lu 2005-08-24, 8:24 pm |
| Good afternoon,
A question about varchar(1) and char(1).
If we have two tables
test1 (col1 varchar(1), ... ... );
test2 (col1 char(1), ... ... );
In the manuall, it written:
*Tip: * There are no performance differences between these three types,
apart from the increased storage size when using the blank-padded type.
While character(/n/) has performance advantages in some other database
systems, it has no such advantages in PostgreSQL. In most situations
text or character varying should be used instead.
As a result, setup 'col1' to either "varchar(1)" or "char(1)" does not
matter at all?
Thanks a lot,
Emi
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
| |
| Martijn van Oosterhout 2005-08-24, 8:24 pm |
| On Wed, Aug 24, 2005 at 03:06:18PM -0400, Emi Lu wrote:
> Good afternoon,
>
> A question about varchar(1) and char(1).
<snip>
> As a result, setup 'col1' to either "varchar(1)" or "char(1)" does not
> matter at all?
As far as storage goes, nope. Think about it, depending on your
encoding, 1 character might be 4 bytes.
char() adds padding but varchar() doesn't. That's the difference
really...
Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
|
|
|
|
|