Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

performance between varchar(1) vs char(1)

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

like image 497
robinmag Avatar asked Jul 30 '10 02:07

robinmag


2 Answers

In MS SQL VARCHAR(1) uses three bytes of storage and CHAR(1) uses one byte of storage.

CHAR(1) is more efficient than VARCHAR(1) in processing and storage.

The breakeven point on VARCHAR would be anything greater than 3 characters if using variable length data.

If using fixed length then CHAR is always more efficient by two bytes.

REF: http://msdn.microsoft.com/en-gb/library/ms176089.aspx

like image 136
Awk Sod Avatar answered Sep 19 '22 12:09

Awk Sod


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.

like image 34
Walter Mitty Avatar answered Sep 17 '22 12:09

Walter Mitty