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.

The output is far more self-describing that the previous tools were in this area:<br />

database_id object_id index_id index_depth avg_fragmentation_in_percent page_count<br />

----------- ----------- ----------- ----------- ---------------------------- ----------<br />

8 610101214 1 3 0.565885206143896 1237<br />

8 610101214 2 3 1.70731707317073 410<br />

8 610101214 3 2 6.14035087719298 228<br />

(3 row(s) affected)<br />

The function also has a veritable sea of other information available, so feel free to explore further, but<br />

let’s walk through the columns that are most interesting in terms of fragmentation.<br />

A number of fields tell you things like what kind of index structure it is (clustered vs. non-clustered),<br />

number of fragmented pages, and other things of interest. There are also several columns that reside<br />

firmly at the advanced level of advanced <strong>SQL</strong> <strong>Server</strong>, so don’t be too stressed if you don’t understand<br />

every column this function offers.<br />

Stat What It Means<br />

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

database id The <strong>SQL</strong> <strong>Server</strong> internal identifier for the database you want to run the function<br />

against. NULL results in information being returned on all databases. Keep<br />

in mind that by choosing the NULL option, all subsequent parameters must also<br />

be set to NULL. 0 and DEFAULT all are functionally equivalent to NULL for this<br />

parameter.<br />

object id The <strong>SQL</strong> <strong>Server</strong> internal identifier for the table you want to run the function<br />

against. NULL results in information being returned on all tables. Keep in mind<br />

that by choosing the NULL option, all subsequent parameters must also be set to<br />

NULL. 0 and DEFAULT all are functionally equivalent to NULL for this parameter.<br />

index id The internal identifier for the index you want to run the function against. NULL<br />

results in information being returned on all indexes. Note that if the table is<br />

clustered, the clustered index will always be numbered 1, and if the table is a<br />

heap, then the heap will be index 0. Non-clustered indexes will be numbers 2<br />

or higher. By choosing the NULL option, partition_no must also be set to<br />

NULL. -1 and DEFAULT all are functionally equivalent to NULL for this parameter.<br />

partition no This is a bit beyond the scope of this book, but tables and indexes can be partitioned<br />

into separate physical storage units. Use this parameter to identify a<br />

specific partition you want fragmentation information on. NULL results in<br />

information being returned on all partitions. 1 and DEFAULT all are functionally<br />

equivalent to NULL for this parameter.<br />

Mode Mode defines the level of scan used to generate the statistics returned. Choices<br />

include DEFAULT, NULL, LIMITED, SAMPLED, or DETAILED. DEFAULT and NULL<br />

are functionally equivalent to LIMITED.<br />

Continued<br />

293

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

Saved successfully!

Ooh no, something went wrong!