views:

103

answers:

3

Is there any performance difference between varchar(1) and char(1)? Which RDBMS handle these two datatypes and sizes in different ways?

+1  A: 

it hardly matters, since you are using 1 byte in both cases.

but long story short, varchar is variable size & char is fixed size. in large quantities this can make a difference in storage space as well as affect computation time.

performance wise, use char if data is going to be fixed length. if you are flexible with varying length of your data then use varchar.

SoftwareGeek
+1  A: 

As far as Oracle is concerned....

CHAR(2) will always use two bytes/characters of storage. VARCHAR2(2) may only use one. So the general case is to use VARCHAR2 instead of CHAR.

In practice you shouldn't see a difference performance wise for a one character column.

Since there's never a never a benefit from CHAR, I always use VARCHAR2.

Gary
The varchar will still have to store at least a byte for the length of the string, though, so you can never have less than 1 byte.
Gabe
+1  A: 

The difference will be negligible in most cases. Concentrate your performance oriented design efforts in places where it will make a real difference, like table composition and index design.

It helps to divide the design effort into two layers: logical design and physical design.
Most of the performance oriented effort is in the second stage, physical design.

In logical design, flexibility trumps performance. Except when it doesn't.

Walter Mitty
Flexibility should almost never trump performance! I guarantee the user wants performacne over flexibility even when they say they want flexibility.
HLGEM