SQL Server 2008 Indexing Tips And Tricks

by Al Tenhundfeld on Aug 22, 2008 |
Bill Vaughn, MS MVP and author of the popular Hitchhiker's Guide SQL Server books, provides a roundup of SQL Server indexing tips and tricks. The topics are based on guidance from Kimberly Tripp and Paul Randall, SQL Server high availability and performance experts.

Highlights from the list:
  • Page Density
    Optimize Row Size: SQL Server 2005 (and later) supports 8K columns. This means a row can be, well, over 80K. Does this make sense? Ah, not usually. Managing row size is as important as ever to those interested in efficiency. The trick to good performance and good use of space is to make sure that when the 8K page is filled with rows, there is little wasted space. This means that if the row size is over (about) 4K, only one row will fit on a page and (about) 4K of space is wasted on the page. A secondary problem is that the number of index pages also has to increase to address the pages.
  • Filtered Indexes
    New for SQL Server 2008, permit you to add a WHERE clause to an index, thus focusing the index on the most important rows.
  • Selectivity
    Selectivity: When the query optimizer (QO) studies your SQL, the degree of selectivity determines if an index should be used to perform the operation. By processing the Statistics (or "stats") for an index (and an index can have from one to many (many) sets of stats), the QO can determine the selectivity. Basically, it's weighing the choice of using the index to walk through the selected rows or doing a table scan. The example Kimberly used made it pretty clear how it worked but we were surprised to learn: "When the number of rows (selected by the query) is around 1/4 of the number of data pages in the table, the index was not useful and it is more efficient to perform a table scan to fetch the rows selected. This often turns out to be less than 5% of the rows in the table..."
The standard practices from SQL Server 2005 around index statistics, column selection, index fragmentation, and locking still apply.

Tripp and Randall also call out the DTA, a.k.a. Data Engine Tuning Advisor, as a valuable tool. The DTA has been updated in SQL Server 2008 to provide new features, including Improved Workload Parsing, Enhanced Scalability, Multiple Database Tuning, Improved Scripting Support Through dta command line interface.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

General Feedback
Marketing and all content copyright © 2006-2016 C4Media Inc. hosted at Contegix, the best ISP we've ever worked with.
Privacy policy

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.