David Walker-278941 (11/23/2010)
"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.
I'm confused about this comment as well....
Since we aren't shown a table definition with details about the clustered index, the only thing I could come up with is a scenario where the clustered index is "wider" (contains more data) than the non-clustered index. Thus the non-clustered index would be smaller and therefore preferred from an efficiency perspective. Maybe. If this was a heap would the RID be smaller, and the optimizer prefer a table scan? I don't know...
I'm getting a little tired of all the jerkoffs who immediately jump in with comments like "You shouldn't be writing SQL code." Do you suppose anyone believes you were born with the ability to write perfect code? That's how people learn - try, make mistakes, try again, read, ask questions, post comments, listen to advice, tune your skills, swap ideas. If nobody did anything until they were perfect at it, nothing would ever get done, anywhere, by anybody.
Get over yourselves - you've made mistakes and written garbage code too, we all have. The trick is to learn from it, and if you're prepared for possible admission to the human race, help others learn as well.
Good manners are a nice plus, but if you can't post something that's at least helpful, go troll under someone else's bridge.
Anyone posting an article or script to be published for the entire community to benefit from (or to be nit picked incessantly) deserves to be treated with respect. Even if an author gets it quite wrong, if the follow-up discussion is professional and without personal attacks on a persons character or education then we can still learn something.
For anyone who thinks writing a submissible article or script is easy, I can say from experience that it's not. So to Sarvesh Singh I say keep trying and don't get discouraged!
On what scenarios we find this Index? Will it reduce time complexity if we use it?
Please provide some more examples?
I expected proof that there was a performance difference between the order of columns in a composite index or a performance difference in the order of columns in the where-clause.
You won't find that because the order of columns in a where clause is utterly irrelevant. It makes no difference what order you specify the where clause predicates.
The order of columns in an index is very important, not so much for a single query, but for when you're trying to get as few indexes as possible to support as many queries as possible.
Several links to my blog posts on this have already been posted here, so I won't post again. Go and read over them.
I still think that the title is misleading. Maybe something along the lines: 'Primary Column in a Composite Index is the most Important'.
It's not. The order of columns (all of them) is important. Maybe the leading column is the most important, but the order of the rest of the columns in the index is important too.
Order of columns in where clause has performance impact in multiple predicates, even if you will see the same nice index seek for all of them. There are several great articles on this subject.
Viewing 4 posts - 46 through 48 (of 48 total)