﻿<?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  / Question about included columns in nonclustered indexes: Where exactly are they stored? / 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>Fri, 24 May 2013 11:02:03 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>[quote][b]Kristian Ask (11/19/2012)[/b][hr]If the included columns is not creating a covering index, will the included columns still be read or is it then only using the table?[/quote] yes they will be retrieved with the help of keylook up or RID lookup.</description><pubDate>Mon, 19 Nov 2012 04:35:38 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>The included columns will still be read.</description><pubDate>Mon, 19 Nov 2012 04:03:47 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>I got it... sound logical. One more thing though.If the included columns is not creating a covering index, will the included columns still be read or is it then only using the table?</description><pubDate>Mon, 19 Nov 2012 03:01:47 GMT</pubDate><dc:creator>Kristian Ask</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>[quote][b]Kristian Ask (11/16/2012)[/b][hr]I know it's an old topic but how is included columns affecting memory footprint? Some say higher use to put index in.memory cache. Some say lower since less pages are read and cached since it is in the index.K[/quote]There is less memory footprint because the idea behind a non-clustered index with INCLUDE columns is to help avoid bookmark lookups in the query plan. Bookmark lookups are operations that go and fetch data from the clustered index (ie. the actual table) to help return columns that are in the SELECT portion of the query. Imagine a very wide table with tens or hundreds of columns being loaded into memory for the bookmark lookup. The memory footprint will be higher than if only a select few columns are instead loaded into memory as include columns in a noncl. Index.Does my somewhat muddled explanation make sense? :-)</description><pubDate>Sat, 17 Nov 2012 10:28:40 GMT</pubDate><dc:creator>Marios Philippopoulos</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>I know it's an old topic but how is included columns affecting memory footprint? Some say higher use to put index in.memory cache. Some say lower since less pages are read and cached since it is in the index.K</description><pubDate>Fri, 16 Nov 2012 08:13:57 GMT</pubDate><dc:creator>Kristian Ask</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>Actually, the included columns make the leaf index entries larger. Therefore, fewer entries per page, which translates to more B-tree above. So there is a size cost for the entire tree structure based on the percent increase in size in the index entry. Increase in tree depth and seek time will be logarithmic increase.Still, well defined include columns can yield a big improvement.</description><pubDate>Tue, 23 Nov 2010 13:01:38 GMT</pubDate><dc:creator>DLathrop</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>[b][/b][quote][b]GilaMonster (10/1/2008)[/b][hr][quote][b]Maxer (10/1/2008)[/b][hr]It seems like it grabs Phone and Email from its leaf level, but still has to jump to the clustered index to get the Fname and Lname since it doesn't actually store those data values in the index, just pointers to them...[/quote][b]FName and LName are the index keys, so they are stored at all levels of the index. They have to be, how else would SQL be able seek on those columns.[/b]In a nonclustered index, the nonclustered index keys and the clustered index keys are stored at all levels of the index. The include columns are only stored at the leaf level. The clustering keys are there as a 'pointer' to the row, in case a bookmark lookup is required.[/quote]Ah, of course.  Indeed otherwise how would it be able to seek on those columns :)Well that explains that.Thanks for pointing out my obvious logical error there.  I knew I was failing to take something into account, and that would certainly be it!</description><pubDate>Wed, 01 Oct 2008 13:34:21 GMT</pubDate><dc:creator>Maxer</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>[quote][b]Maxer (10/1/2008)[/b][hr]It seems like it grabs Phone and Email from its leaf level, but still has to jump to the clustered index to get the Fname and Lname since it doesn't actually store those data values in the index, just pointers to them...[/quote]FName and LName are the index keys, so they are stored at all levels of the index. They have to be, how else would SQL be able seek on those columns.In a nonclustered index, the nonclustered index keys and the clustered index keys are stored at all levels of the index. The include columns are only stored at the leaf level. The clustering keys are there as a 'pointer' to the row, in case a bookmark lookup is required.</description><pubDate>Wed, 01 Oct 2008 12:59:19 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>The columns defined in the INCLUDE statement are stored at the leaf level of the non-clustered index. There's no need to go to the cluster or a heap to retrieve the data. Storing the data increases the size of the index, but it doesn't change the size and levels of the B-Tree since the index keys are still the same. That means, for the most part, the index seek operations should be as fast as ever.</description><pubDate>Wed, 01 Oct 2008 12:18:16 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>Question about included columns in nonclustered indexes: Where exactly are they stored?</title><link>http://www.sqlservercentral.com/Forums/Topic579285-360-1.aspx</link><description>I figured an indexing question would best be answered by folks who focus on performance tuning, if there was a better forum for this please let me know.Anyway I was looking at: http://msdn.microsoft.com/en-us/library/ms177484(SQL.90).aspx  and an article talking about indexing.With included columns you can add them to a NONclustered index so that when a query uses that index additional columns the query SELECTs can be "included columns" and returned as part of the INDEX SEEK instead of having to hop over to the table, lookup the table row, and then scan that row of the table to get whatever columns are needed.Classic example:nonclustered index on: FirstName, LastName.included columns: EmailAddress, PhoneNumberThe table would also of course have a PK which is part of the clustered index.The clustered index might have other columns, maybe LastName or "whatever".It sorts the table and is used to quickly locate records.  Here is what I don't get:I do my query: SELECT FirstName, LastName, EmailAddress, PhoneNumberFROM tableWHERE FirstName = 'John' AND LastName = 'Doe'It then uses my NONclustered index to perform my query AND it would then locate the record(s) that match my criteria.What happens then?It looks like it would then have a pointer to the clustered index which it would use to locate the record in the table, and retrieve the data.Except in this case it is a COVERING INDEX... and it has Email and Phone stored in the NONclustered index's leaf level.So... what does it do?Does it grab Email and Phone and THEN still jump to the clustered index to locate the row in the table so it can pull out First and Last Name?What I'm getting at is this:CLUSTERED indexes store the actual table at their leaf level, is that correct?NONclustered stores pointers to the clustered index (the table) or to artificial keys in a heap (tables with no clustered index), right?So... how does the included column on a NONclustered index allow the query to avoid having to lookup the data in the table itself?That's the part I don't get.It seems like it grabs Phone and Email from its leaf level, but still has to jump to the clustered index to get the Fname and Lname since it doesn't actually store those data values in the index, just pointers to them...So what am I not following/understanding?Thanks!</description><pubDate>Wed, 01 Oct 2008 11:55:56 GMT</pubDate><dc:creator>Maxer</dc:creator></item></channel></rss>