17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Page Splits<br />

When a page becomes full, it splits. This means more than just a new page being allocated — it also<br />

means that approximately half the data from the existing page is moved to the new page.<br />

The exception to this process is when a clustered index is in use. If there is a clustered index and the next<br />

inserted row would be physically located as the last record in the table, then a new page is created, and<br />

the new row is added to the new page without relocating any of the existing data. We will see much<br />

more on page splits as we investigate indexes.<br />

Rows<br />

You have heard much about “row level locking,” so it shouldn’t be a surprise to hear this term. Rows<br />

can be up to 8KB.<br />

In addition to the limit of 8,060 characters, there is also a maximum of 1,024 standard (non-sparse)<br />

columns. In practice, you’ll find it very unusual to run into a situation where you run out of columns<br />

before you run into the 8,060 character limit. 1,024 gives you an average column width of just under<br />

8 bytes. For most uses, you’ll easily exceed that average (and therefore exceed the 8,060 characters before<br />

the 1,024 columns). The exception to this tends to be in measurement and statistical information — where<br />

you have a large number of different things that you are storing numeric samples of. Still, even those<br />

applications will find it a rare day when they bump into the 1,024-column-count limit. When you do,<br />

you can explore the notion of sparse columns, so let’s look at that.<br />

Sparse Columns<br />

Chapter 9: <strong>SQL</strong> <strong>Server</strong> Storage and Index Structures<br />

Sparse columns, in terms of a special data structure, is new with <strong>SQL</strong> <strong>Server</strong> <strong>2008</strong>. These are meant to deal<br />

with the recurring scenario where you have columns that you essentially just need “sometimes.” That is,<br />

they are going to be null a high percentage of the time. There are many scenarios where, if you bump<br />

into a few of these kinds of columns, you tend to bump into a ton of them. Using sparse columns, you<br />

can increase the total number of allowed columns in a single table to 30,000.<br />

Internally, the data from columns marked as being sparsely populated is embedded within a single<br />

column — allowing a way to break the former limitation of 1,024 columns without major architectural<br />

changes.<br />

Image, text, ntext, geography, geometry, timestamp, and all user-defined data types are prohibited<br />

from being marked as a sparse column.<br />

While sparse columns are handled natively by newer versions of the <strong>SQL</strong> Native<br />

Client, other forms of data access will have varying behavior when accessing sparse<br />

columns. The sparse property of a column will be transparent when selecting a column<br />

by name, but when selecting it using a “*” in the select list, different client<br />

access methods will vary between supplying the sparse columns as a unified XML<br />

column vs. not showing those columns at all. You’ll want to upgrade your client<br />

libraries as soon as reasonably possible.<br />

263

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!