views:

78

answers:

2

In one of my very previous company we used to have a separate table that we stored long descriptions on a text type column. I think this was done because of the limitations that come with text type.

Im now designing the tables for the existing application that I am working on and this question comes to my mind. I am resonating towards storing the long description of my items on the same item table on a varchar(max) column. I understand that I cannot index this column but that is OK as I will not be doing searches on these columns.

So far I cannot see any reason to separate this column to another table.

Can you please give me input if I am missing on something or if storing my descriptions on the same table on varchar(max) is good approach? Thanks!

+1  A: 

It depends on how often you use them, but yes, you may want the on a separate table. Before you make the decision, you'll want to read up on SQL file paging, page splits, and the details of "how" sql stores the data.

The short answer is that varcharmax() can definitely cause a decrease in performance where those field lengths change a lot due to an increase in page splits which are expensive operations.

Russell Steen
does keeping varchar(max) columns on the same table decrease tables performance even I am doing queries to the table to retrieve data that does not include the description columns(This would be the key for me)? I am also curious if these performance decreases are significant ones enough to separate columns to other tables. I just don't wanna do unnecessary work for something negligable ..
kaivalya
Maybe. It depends on how often the fields are updated. If they are INSERT once only, and rarely updated, then it's not as much of a concern.Whether or not performance increases will be signficicant is really something you can only know by modelling your specific scenario. Fill a table with an expected number of rows. Kick off one machine doing inserts and updates at about the rate you expect, and then with another, start firing off large numbers of selected. Measure the performance Create a new db with the different layout and test again.
Russell Steen
+3  A: 

Keep the fields in the table where they belong. Since SQL Server 2005 the engine got a lot smarter in regard to large data types and even variable length short data types. The old TEXT, NTEXT and IMAGE types are deprecated. The new types with MAX length are their replacement. With SQL 2005 each partition has 3 types of underlying allocation units: one for rows, one for LOBs and one for row-overflow. The MAX types are stored in the LOB allocation unit, so in effect the engine is managing for you a separate table to store large objects. The row overflow unit is for in-row variable length data that after an update would no longer fit in the page, so it is 'overflown' into a separate unit.

See Table and Index Organization.

Remus Rusanu
Awesome information, thank you. +1
Russell Steen