﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Performance Tuning  / Covering Index vs Included Columns / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 00:47:47 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>As for the covering index vs. include topic, I would recommend reading an article by Josef Richburg and the ensuing discussion on the topic.  You can find the article [url=http://www.sqlservercentral.com/articles/included+columns/69179/]here[/url].I would also recommend reading up on Gail Shaws articles on the topic.  You can find her first article in the series [urlhttp://www.sqlservercentral.com/articles/Indexing/68439/]here[/url].In the discussion on Josef's article, it is pointed out that the space saved is negligible between the covering index and the include.  Also, Matt's answer pretty much nailed it otherwise.</description><pubDate>Tue, 13 Apr 2010 17:50:10 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>[quote][b]tfifield (5/30/2008)[/b][hr]Can anyone tell me if there is any functional or performance difference between designing a covering index and an index that includes columns that will be queried.[/quote]Hi,I'd like to point out that a covered index contains all columns in every node of the index while a index with included columns only contains all columns on the leaf level.I.e. a Covered index is wider in every node, hence takes more space and will be less performant for queries of the typeSELECT col1,col2,col3FROM tab1WHERE col1=... AND col2=...(where col1 and col2 are in both types of indexes and col3 is in the covered index but Included in the 'Included Columns Index')Regards,Hanslindgren</description><pubDate>Tue, 13 Apr 2010 03:12:31 GMT</pubDate><dc:creator>Hans Lindgren</dc:creator></item><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>[quote][b]Matt Miller (#4) (5/30/2008)[/b][hr][code]CREATE NONCLUSTERED INDEX IX_OrderDetailDateProdSold ON dbo.OrderDetail( OrderDate ASC, ProductID ASC) INCLUDE (QtySold);[/code][/quote]Matt,Any specific reasons you wouldn't go for:[code]CREATE NONCLUSTERED INDEX IX_OrderDetailDateProdSold ON dbo.OrderDetail( [b]ProductID ASC, OrderDate ASC[/b]) INCLUDE (QtySold);[/code]which (quite probably.Here I assume more products then dates in your solution) would have a much higher cardinality and would be far more effictive?Regards,Hans</description><pubDate>Tue, 13 Apr 2010 03:03:57 GMT</pubDate><dc:creator>Hans Lindgren</dc:creator></item><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>Thanks guys.  It makes sense  I'll give it a whirl.Todd Fifield</description><pubDate>Sat, 31 May 2008 11:01:42 GMT</pubDate><dc:creator>tfifield</dc:creator></item><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>I think Matt covered it very well.  Another way to explain it that the included columns should be columns that you don't search on, but will return.  I think a good example are middle_name and suffix columns.  You probably return it but your searching, ordering, and grouping will usually be by last_name, first_name which would be your index with middle_name and suffix as the included columns.</description><pubDate>Fri, 30 May 2008 13:06:14 GMT</pubDate><dc:creator>  Jack Corbett</dc:creator></item><item><title>RE: Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>There should be, although how much might be debatable.  Ultimately - I think the "sweet spot" is the version you didn't include:[code]CREATE NONCLUSTERED INDEX IX_OrderDetailDateProdSold ON dbo.OrderDetail( OrderDate ASC, ProductID ASC) INCLUDE (QtySold);[/code]The short version as I understand it to make the "ideal" covering would be:  - columns appearing in the WHERE, FROM, GROUP BY and ORDER BY should appear in the "main part" of the index. - columns not otherwise included that appear in the SELECT or HAVING go in the UNCLUDE clause.Technically - since the "main part" is what the B-tree is based on - by keeping the main part as skinny as you can, you get better perf, while avoiding the bookmark lookup with the INCLUDE stuff.</description><pubDate>Fri, 30 May 2008 12:53:18 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>Covering Index vs Included Columns</title><link>http://www.sqlservercentral.com/Forums/Topic509318-360-1.aspx</link><description>Hi Guys!Can anyone tell me if there is any functional or performance difference between designing a covering index and an index that includes columns that will be queried.Let's say I wanted to sum up the total quantity ordered by product in a date range.SELECT ProductID, SUM(QtySold) AS MarchQtyFROM OrderDetailWHERE OrderDate &amp;gt;= '3/1/08'AND     OrderDate &amp;lt; '4/1/08GROUP BY ProductIDWould there by any performance difference between:CREATE NONCLUSTERED INDEX IX_OrderDetailDateProdSold ON dbo.OrderDetail( OrderDate ASC, ProductID ASC, QtySold ASC );andCREATE NONCLUSTERED INDEX IX_OrderDetailDateWithProdSold ON dbo.OrderDeail(OrderDate) ASCINCLUDE (ProductID, QtySold);</description><pubDate>Fri, 30 May 2008 12:39:44 GMT</pubDate><dc:creator>tfifield</dc:creator></item></channel></rss>