Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 Performance Tuning
»
basic guidelines on creating Indexes
basic guidelines on creating Indexes
Rate Topic
Display Mode
Topic Options
Author
Message
Joy Smith San
Joy Smith San
Posted Thursday, March 26, 2009 11:09 PM
Ten Centuries
Group: General Forum Members
Last Login: Yesterday @ 6:42 AM
Points: 1,370,
Visits: 2,285
Dear All,
Can anyone give me basic guidelines on creating Indexes...pls.
Thanks in advance.
Post #684771
Grant Fritchey
Grant Fritchey
Posted Friday, March 27, 2009 6:05 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 4:50 AM
Points: 13,371,
Visits: 25,143
That's a very broad topic. Here are a few of my personal pointers
1) Pick the clustered index first and pick it carefully
2) Keep the clustered index as narrow as practical (note: not as narrow as possible, narrow means smaller data types and fewer columns)
3) Usually the most frequently accessed data path is the best place for the clustered index since that's where the data is stored.
4) Create nonclustered indexes only when you know you need them. Create as few as possible and keep them as narrow as practical too.
5) Test, test, test, test, test, test
6) Test some more.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #684939
maechismo_8514
maechismo_8514
Posted Friday, March 27, 2009 7:12 AM
Ten Centuries
Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097,
Visits: 2,157
swmsan (3/26/2009)
Dear All,
Can anyone give me basic guidelines on creating Indexes...pls.
Thanks in advance.
Let me give a shot too:
1.) There should be atleast one clustered index for a table which should be Narrow, ever-increasing, unique
2.) Try think of creating clustered indexes on the ones which are used in range queries and the ones which are used for ORDER by clause
3.) Frequently updated columns and non-unique columns are not a good choice
4.) Non- clustered indexes when needed but be careful about the number of indexes . more number of indexes more performance overhead on your table for DML operations
5.)Think about Covering indexes to cover all the columns retrieved in your query
6.) Order of Index columns pretty important as SQL server maintains indexes only on the lading edge of the indexed columns
7.) Give consideration about fill factor too when creating indexes, inappropriate fill factor may lead to index fragmentation
Post #685014
GilaMonster
GilaMonster
Posted Friday, March 27, 2009 2:05 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 2:48 AM
Points: 37,635,
Visits: 29,886
Krishna (3/27/2009)
1.) There should be at least one clustered index for a table which should be Narrow, ever-increasing, unique
At least one?
5.)Think about Covering indexes to cover all the columns retrieved in your query
Not all queries can be covered, not all queries should be covered. Sometimes the cons outweigh the pros. (Think of the size of a very large covering index)
6.) Order of Index columns pretty important as SQL server maintains indexes only on the lading edge of the indexed columns
I assume you mean statistics on the leading column?
There's a lot, lot more to order of columns that that. I wrote two blog posts on just that topic
http://sqlinthewild.co.za/index.php/2009/01/19/index-columns-selectivity-and-equality-predicates/
http://sqlinthewild.co.za/index.php/2009/02/06/index-columns-selectivity-and-inequality-predicates/
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 #685375
maechismo_8514
maechismo_8514
Posted Friday, March 27, 2009 2:13 PM
Ten Centuries
Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097,
Visits: 2,157
GilaMonster (3/27/2009)
Krishna (3/27/2009)
1.) There should be at least one clustered index for a table which should be Narrow, ever-increasing, unique
At least one?
OMG what am I saying- only one
5.)Think about Covering indexes to cover all the columns retrieved in your query
Not all queries can be covered, not all queries should be covered. Sometimes the cons outweigh the pros. (Think of the size of a very large covering index)
Definitely not there are cons as well, but gave a basic idea
6.) Order of Index columns pretty important as SQL server maintains indexes only on the lading edge of the indexed columns
I assume you mean statistics on the leading column?
yes, ahh may be am smoking something when i was typing.
thanks for pointing it out. next time should be careful while typing.....
Post #685384
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.