Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Char vs Varchar
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Database design
Title:
Miscellaneous
Thread ID:
00492249
Message ID:
00493846
Views:
14
>I'm going to guess that using varchars would lead to faster performance due to the fact that only the necessary space is allocated. The less space means the more rows fit on a page which means that there are less page I/Os. The same for indexes. The smaller the key the more keys per page.
>
>Are you going to use Analysis Services 2000 for your datawarehouse?
>
>-Mike

Mike,
My understanding is that although VARCHAR may allocate less space than CHAR, CHAR are placed on the left side of a page in fixed positions. VARCHAR are variable in length and therefore SQL Server need to calculate their beginning and ending positions. If you had several VARCHAR columns on the page that would slow everything down. It would seem to me that CHAR would be much faster to retrieve off disk then VARCHAR.

In my designs I use the following rules: If a column is 20 characters or less always use a CHAR and if the field contents will average over 80% full use a CHAR. I also try to optimize the bites per row so that they fit on a single page.

If speed of retrieval of non-indexed columns is more important than table size stick with CHAR.
Software engineers are trained to read and understand code; they are not trained in mind reading. Document the purpose not just the functionality.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform