join the MSSQLTips community

Today's Site Sponsor


 

Find performance issues related to Analysis Services memory limits.
 


Improve Performance with SQL Server 2005 Covering Index Enhancements
Written By: Edgewood Solutions Engineers -- 9/29/2006 -- 1 comments -- printer friendly -- become a member



Free SQL Server Performance Dashboard & Screensaver

        Win SQL Books  -----  SharePoint Tips  -----  Live Webcast - SQL Backup Mistakes  -----  Bookmark and Share        

Problem
The concept of index creation has always been a tricky orchestration.  To maximize performance and indexes by the optimizer, queries should be covered by an index-that is, the index should include all columns requested in the query.  There are limitations to creating indexes that make covering queries difficult:

  • A 900-byte size limit on indexes
  • A maximum of 16 columns can be named in the index
  • Columns with data types like nvarchar(max), text, and ntext cannot be used in indexes

Solution
A new type of index was developed in SQL Server 2005 that assists in covering queries: Indexes With Included Columns.  Indexes with Included Columns are nonclustered indexes that have the following benefits:

  • Columns defined in the include statement, called non-key columns, are not counted in the number of columns by the Database Engine. 
  • Columns that previously could not be used in queries, like nvarchar(max), can be included as a non-key column
  • A maximum of 1023 additional columns can be used as non-key columns

As with traditional non-clustered indexes, the non-key columns are added to the leaf level of the index, meaning these indexes have the same affect on disk space, I/O (due to index maintenance), and cache efficiency.  This should be taken into account when contemplating index creation using included columns. 

How do I create an Index with Included Columns?

Using Microsoft SQL Server Management Studio

Navigate to the index to be modified.  Right-click the index and choose Properties:

Click on Included Columns:

Check the columns you wish to include and click OK:


Using Transact-SQL:

Next Steps

Readers Who Read This Tip Also Read Comment or Ask Questions About This Tip Twitter This Tip!


Sponsor Information
Free SQL Server performance monitoring dashboard – Idera SQL check

The SQL Toolbelt – all 13 Red Gate SQL Server Tools.

SQL Server Issues? Not sure where to turn for answers? Innovative SQL DBA consultants

Looking for SQL Server interview questions and answers?

Learn SQL Server 2008, Performance Tuning, Development, Administration, DR, Replication and more from these web casts

Make the most of MSSQLTips...Sign-up for the newsletter

Getting started with SharePoint? Start your journey with MSSharePointTips.com...

Free whitepaper - Ten Things DBAs Need to Know About Storage


 

 



Red Gate Software - SQL Backup

Need to create smaller, more reliable backups? Ensure your backups are optimized for robustness and speed with Red Gate SQL Backup Pro. Compress your backups by up to 95% and minimize disruptions to your backups caused by flaky networks with new network resilience. 'Network resilience puts SQL Backup Pro 6 at the top of the list of backup tools. It’s the cherry on top, and I definitely recommend using SQL Backup over SQL Server 2008 native backups.' William Durkin, Development DBA. Download now.

Download now!

More SQL Server Tools
SQL safe backup

SQL compliance manager

SQL Prompt

SQL Compare

SQL defrag manager




Copyright (c) 2006-2010 Edgewood Solutions, LLC All rights reserved
privacy statement | disclaimer | copyright | advertise | write for mssqltips | feedback | about
Some names and products listed are the registered trademarks of their respective owners.