Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Stairway to SQL Server Indexes: Level 15, Indexing Best Practices Expand / Collapse
Author
Message
Posted Monday, July 11, 2011 3:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, June 23, 2012 10:54 AM
Points: 8, Visits: 23
Comments posted to this topic are about the item Stairway to SQL Server Indexes: Level 15, Indexing Best Practices
Post #1139626
Posted Monday, July 11, 2011 3:48 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, April 10, 2014 5:14 AM
Points: 91, Visits: 521
You repeat explanation of "Consider Using a Foreign Key in the Search Key of the Clustered Index" in "Consider Having Included Columns in your Indexes "
Post #1139629
Posted Wednesday, July 13, 2011 12:21 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, April 15, 2014 5:55 AM
Points: 105, Visits: 81
Thanks for putting the effort into writing this complete guide. It's made a lot of things and issues a lot more clear to me.
Post #1140752
Posted Monday, August 22, 2011 4:28 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 29, 2011 2:15 PM
Points: 4, Visits: 71
all the articles were amazing i got a better idea on how to implement indexes using best practices
Post #1163669
Posted Tuesday, September 13, 2011 11:51 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 8:40 AM
Points: 51, Visits: 316
My reason for creating a clustered index on RID is that
Where using the non clustered index for joins or queries, if the RID was an output of the query or join, then it will be satisfied by an index seek or scan without having to do an RID lookup, hence behaving like an included index.
Else, you will be hit with RID lookup, if table is a heap.
Execution plans also become easier to optimise [seek plus lookup becomes only seek]so SQL can make a better choice of what to do.

Secondly a scan of RID is faster than if it was a scan of nonclustered index, in the cases where scans are unavoidable, 64k reads on clustered index pages vs (8k reads and jumping between non clustered index and Table).
Post #1174647
Posted Thursday, February 23, 2012 3:06 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, March 20, 2014 9:57 AM
Points: 20, Visits: 81
Two comments:
1) Thanks for writting the series. It is always nice to review information. Being reminded of something useful or learning something new is always a pleasant surprise. I think I was both reminded of something useful and learned something new in this series.

2) In the final segment, your comments for the following sections are identical:
-Consider Using a Foreign Key in the Search Key of the Clustered In
-Consider Having Included Columns in your Indexes
Post #1256961
Posted Wednesday, March 28, 2012 2:17 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:30 PM
Points: 41,531, Visits: 34,448
One guideline I strongly disagree with...

Avoid Nonclustered, Unfiltered Indexes on Columns that have few Distinct Values
The old cliché is “Never index the Gender column”. A typical page of the table will have half female rows and half male rows, and will be accessed whether the request is for female rows or for male rows. A table scan will always be the best decision for any WHERE GENDER = … query; therefore, such an index will never be of benefit to the optimizer.


Not at all. While an index on just the Gender column may not be very useful, an index that starts with the gender column, perhaps has other key columns and maybe an include column or two can be very, very useful indeed, especially if you have a lot of queries that filter on gender and ...

A table scan will not always be the best decision for a filter on a high density column (high density = not very unique). If the index on the column is covering, seeks can and will be used even up to cases where 100% of the rows in the table affected by the query.

Also
Consider Using a Foreign Key in the Search Key of the Clustered Index


Maybe, but by doing so you're losing the ever-increasing attribute that is suggested for clustered indexes and maybe (depending what the other key columns are and if the foreign key every changes) the narrow, unchanging and unique as well



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

Post #1274126
Posted Wednesday, March 28, 2012 7:59 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 23, 2012 8:58 AM
Points: 6, Visits: 18
Thanks for very clear overview of indexing considerations. A related topic that is sometimes overlook is the challenge of predicting the effects of an individual index on the workload as a whole. A recent article by Ami Levin, The Hidden Menace of CREATE INDEX, highlights this issue with some vivid examples. Worth a read.
Post #1274318
Posted Wednesday, March 28, 2012 11:29 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, April 10, 2014 2:18 PM
Points: 34, Visits: 179
In the Indexing best practices
Here is another avoid

Avoid using fields in indexes that are updated frequently.
Status fields are a prime example. Each time the field is updated the index has to be updated.
This is a major cause of deadlocking on the index structures of one application where I am currently employed and has caused me endless grief.
There are 6 different statuses as the record proceeds through our system and a dashboard watches it real time from created, validated, ready, processing, sent, complete. Each time causes the index to be updated as well.
Post #1274508
Posted Wednesday, March 28, 2012 12:54 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:30 PM
Points: 41,531, Visits: 34,448
bwilliams-1049831 (3/28/2012)

Avoid using fields in indexes that are updated frequently.
Status fields are a prime example. Each time the field is updated the index has to be updated.


Maybe. Depends on how often that field is filtered on, how important the queries that filter on it are, etc. It's a tradeoff and has to be evaluated case-by-case. If the status is frequently updated but seldom searched on then an index on it would indeed be a bad thing.

Indexes on frequently changing columns don't automatically cause deadlocks, if you're talking about key lookup deadlocks then the usual way to prevent the deadlocks is to ensure the index is covering (or use one of the row version based isolation levels)



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

Post #1274578
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse