|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
Hi All
When I queried dm_db_index_usage_stats, I get user_lookups for a Clustered Index
Here are the numbers
seeks lookups 14723 62569
Question is what do the user_lookups on Clustered Index mean to me? I always thought the lookups are only found for Non-Clustered Index.
Thanks
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Yesterday @ 9:18 AM
Points: 608,
Visits: 1,854
|
|
If you check Gail's explanation here then this should help you. She explains lookups very well.
The other 2 articles in the series are also very useful and worth a read when you get time.
Follow me on Twitter: @WazzTheBadger LinkedIn Profile: Simon Osborne
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
I understand what she says or so I think.
A lookup occurs when a nonclustered index was used to locate rows for a query, but the nonclustered index did not contain all of the columns required for the query. To fetch the remaining columns, a lookup is done to the clustered index.
A lookup is equivalent to a single row clustered index seek. Lookups are always done one row at a time. For this reason, they are very expensive operations, especially when lots of rows are involved
Precisely why I asked the question -- so what does it mean for a Clustered Index. Am I missing something in her article.
Thanks
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, March 26, 2013 9:55 AM
Points: 1,024,
Visits: 2,768
|
|
It means that all the data was reuested in the query was not contained in the nonclustered index. So it used the clustering key contained in the non-clustered index to look up the rest of the columns from the clustered index (which is the table.)
Gethyn Ellis
gethynellis.com
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
Ummm I don't think I have made myselves clear here.
All that you guys are pointing out to me is for a NON CLUSTERED index and I understand that, but then why Do I see the numbers I have posted above for a CLUSTERED Index?
When I query dm_db_index_usage_stats, I see a the number for user_lookups for a Clustered Index. I always thought that number should be 0 for a Clustered Index considering that Clustered Indexes don't have to go through "lookups". Or am I wrong in my assumption.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 12:59 PM
Points: 37,640,
Visits: 29,895
|
|
It's not a lookup from that index. It's a lookup to that index. Typically it will be 0 for nonclustered indexes (because key lookups aren't done to nonclustered indexes) and non-zero for the cluster (because key lookup are done to the clustered index)
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 6:03 PM
Points: 5,658,
Visits: 6,099
|
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
Oh wait a minute Gethyn -- are you trying to say that even though Lookups happen for NON CLUSTERED index -- it uses the CLUSTERED INDEX as a key for Lookups, the number for the Clustered Index in the dm_db_index_usage_stats -- user_lookups column increases by 1 ?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
I see, I understand what you are saying now.
Then this begs the next question -- how do I know which NON_CLUSTERED index used this CLUSTERED index for "lookups" and how many times each did ?
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 9:07 AM
Points: 46,
Visits: 175
|
|
Thanks Craig
I see people have already discussed this. Thanks for pointing this out to me.
|
|
|
|