Raymond Lewallen

Sponsors

The Lounge

Wicked Cool Jobs

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
How Sql Server 2005 bypasses the 8KB row size limitation

Here I talked about row size limitations and using varchar versus nvarchar data in Sql Server.  Now, lets look at what you can do in Sql Server 2005 that allows you to surpase the 8KB row size limit.

Sql Server 2005 still adheres to the 8K page size.  But now, you are allowed to have rows that exceed that limit.  Individual columns still must adhere to 8K limits.  This means you can have a table defined as varchar(5000), varchar(5000), but you cannot have a table defined as varchar(10000).  The same applies with nvarchar, which would be a table with nvarchar(3000), nvarchar(3000), but you’re not allowed nvarchar(5000).  What happens in Sql Server 2005 is that when combinations of varchar, nvarchar, varbinary, sql_variant, or CLR user-defined type columns exceeds the 8K limit, the column for a record with the largest size is moved to another page in what is called a ROW_OVERFLOW_DATA allocation unit, again like Text and Image data, keeping a 24 byte pointer in the original data page, which is the IN_ROW_DATA allocation unit.

This all happens behind the scenes, but understand the performance consequences of this happening.  When you update a row with data that will cause the row to exceed the 8K limit, part of that row is moved to a new page.  If you update a row that is split between pages and it now fits within the 8K limit, this may cause the split row to be merged back into the original data page, both of which cause performance degredation.  Querying data or performing joins on data that have data allocated in the ROW_OVERFLOW_DATA also slows performance because these records are processed synchronously.  If you were to normalize that data so that the data is split between tables and use a JOIN instead of using rows larger than 8K, this speeds your performance back up because JOINS are asynchronous operations.


Posted Fri, Dec 30 2005 9:06 AM by Raymond Lewallen
Filed under:

[Advertisement]

Comments

Scott Whigham wrote re: How Sql Server 2005 bypasses the 8KB row size limitation
on Fri, Dec 30 2005 4:52 PM
Good stuff - I had read that back in Beta 1 PDFs but had totally forgot about that... Thanks :)
Jason Haley wrote Interesting Finds
on Sat, Dec 31 2005 8:35 AM
Diego Reyes wrote re: How Sql Server 2005 bypasses the 8KB row size limitation
on Mon, May 7 2007 1:29 PM

Hello Ray. Perhaps or Sure you can help me.

I have a small table with 3 columns. One is an Integer, the second is XML and the last one is varchar(20). Until here no problem, many rows have a data length more than 8060 kb in the xml data column. Here is the problem, this column was nullable and i wanted to alter this column to Not Null but send me an error "Cannot create a row of size 8088 which is greater than the allowable maximum of 8060"....

What can i do? Thank you a congratulations about your carer.

reyesdiego@hotmail.com

Raymond Lewallen wrote re: How Sql Server 2005 bypasses the 8KB row size limitation
on Wed, May 30 2007 5:21 PM

Diego,

All you are doing is changing the column from allow nulls to not allow nulls?

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us