• hawaiianrebel (10/16/2009)


    See I got it wrong for two reasons:

    I was a knuckle head and missed the "English only" so yes varchar or char. The choice between the two though, to me, is subjective. Yes VARCHAR's do require an additional 2 bytes as length identifiers (remember VSAM? lol). I question is "Their length will vary from seven to ten characters" ... "with an even distribution of lengths" "Since the average size of the data is 8.5". We can't store data in half bytes (unless you are working with assembler. remember 3270 ASM?). In fact we can't store data in perfect little bytes. There are 32 or 64 bit WORD boundaries. For me 8, 12, or 16 would have been more efficient, but that's just the hardware nut in me.

    No, we can't store data in half bytes. But when we multiple units of data, and not all data uses the same number of bytes, we can get fractional bytes for the average unit. The simples example would be two rows, one with 10 bytes and the other with 11 bytes. That means 21 bytes for 2 rows, or an average of 10.5 bytes per row.

    The 32 or 64 bit word boundaries are completely irrelevant in SQL Server. If a row takes 1 byte less, 1 byte less is used. No 16-bit, 32-bit, or 64-bit aligning is done.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/