Hi @sakuraime ,
... so this additional storage cost only valid for varchar(1) or varchar(2) ???
No. It is valid for all the data types of variable length. Not only varchar(1) or varchar(2).
...So In this case , why this will have performance implications ???
Because fixed-width data types always require the same amount of storage, regardless of the value stored in those columns or variables,Variable-width data types always have two extra bytes of overhead.
And quote code from this doc.: sql-varchar-data-type-deep-dive
DECLARE @demochar CHAR(150) = 'This is the char value'
DECLARE @demovarchar VARCHAR(150) = 'This is the varchar value'
SELECT 'Starting ' + @demochar + ' finishing' AS 'CHAR DATA'
SELECT 'Starting ' + @demovarchar + ' finishing' AS 'VARCHAR DATA'
So if you are storing a value, a string value that will always be short, or a one-character value, it is better from a storage perspective to use a CHAR(1) instead of a VARCHAR(1). Even if a VARCHAR(1) field is empty, it will still require two bytes of storage.
More information: data-type-choice-affects-database-performance ,char-vs-varchar-in-sql
BR,
Mia
If the answer is helpful, please click "Accept Answer" and upvote it.