|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, May 28, 2012 10:22 PM
Points: 9,
Visits: 48
|
|
| Good Article to understand Non clustered index usage.
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Today @ 10:38 AM
Points: 36,
Visits: 101
|
|
The article may be short and short on detail, however, the really good thing was that it lead me to this discussion and the links here. Thank you!
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 2:40 AM
Points: 356,
Visits: 1,667
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Friday, June 14, 2013 7:34 AM
Points: 2,865,
Visits: 2,472
|
|
Sarvesh, This was a good article, with the potential to be much better if you were to expand on it. You leave out a lot of why things work this way leaving it at a very entry level atricle.
I think it great that you did the article, but please - put more effort into it. Why does the index work this way? How do statistics impact it? What is the difference between an index scan and an index seek? etc...
Steve Jimmo Sr DBA “If we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354,
Visits: 1,299
|
|
Please don't laugh at me for asking this question.
Why would you create a compound index with both last name and first name together? Why not two separate indexes where one is for last name and the other is for first name. That should handle any combination that you have in your where clause.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 7:21 AM
Points: 898,
Visits: 1,049
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354,
Visits: 1,299
|
|
Thanks for the link but I get "404 - File or directory not found."
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Saturday, November 27, 2010 10:41 PM
Points: 58,
Visits: 113
|
|
cengland0 (11/23/2010) Please don't laugh at me for asking this question.
Why would you create a compound index with both last name and first name together? Why not two separate indexes where one is for last name and the other is for first name. That should handle any combination that you have in your where clause.Because indexes don't work the way you think they do. Indexes sort off their key expression. If that expression contains two columns, the table is sorted by both. If it contains one column only, then its only sorted by that single column, period.
Without getting into too much technical detail, SQL contains an optimization called index intersection that allows two indexes to act a wee bit like one compound index. But "a wee bit" is the operative term here; the performance is not the same.
To use your firstname, lastname example. If you have a single "John Smith" in your table, a compound index will walk the tree right to that record-- all done! No scanning required. Two indexes, one on each column, will only allow the engine to find all Smiths, then find all Johns, then laboriously intersect the result result to find which ones match both criteria.
Performance takes a further hit when you want to order by multiple columns, as a single index will return the rows in proper order, whereas results from intersected indexes must be manually sorted each time.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 7:21 AM
Points: 898,
Visits: 1,049
|
|
seems SSC adds something in front of it, copy/paste: http://sqlinthewild.co.za/index.php/2010/09/14/one-wide-index-or-multiple-narrow-indexes/
Wilfred The best things in life are the simple things
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, April 05, 2013 12:29 PM
Points: 67,
Visits: 227
|
|
"This does not mean that the index 'NonClust_Contact_Name' was not useful. It's still much better than the Clustered scan."
*WHAT* is still much better than the clustered scan? I'm confused by that last sentence.
|
|
|
|