SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


When to use a clustered and/or non-clustered index


When to use a clustered and/or non-clustered index

Author
Message
itmasterw 60042
itmasterw 60042
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1081 Visits: 305

Hi,

I have been looking all over the net and in books to findwhen to use a clustered and/or non-clustered index; and all I get isdefinitions, not when to use one or both. Can you please tell me how I canlearn this, or would you be able to give me some general steps to do this?

Thank you


Sean Lange
Sean Lange
SSC Guru
SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)SSC Guru (236K reputation)

Group: General Forum Members
Points: 236437 Visits: 19110
itmasterw 60042 - Thursday, August 3, 2017 9:23 AM

Hi,

I have been looking all over the net and in books to findwhen to use a clustered and/or non-clustered index; and all I get isdefinitions, not when to use one or both. Can you please tell me how I canlearn this, or would you be able to give me some general steps to do this?

Thank you



The stairways article series right here on this site is absolutely fantastic. http://www.sqlservercentral.com/stairway/72399/
Once you fully understand indexes it becomes second nature if a given index should be clustered or nonclustered.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)

Group: General Forum Members
Points: 148860 Visits: 22100
itmasterw 60042 - Thursday, August 3, 2017 9:23 AM

Hi,

I have been looking all over the net and in books to findwhen to use a clustered and/or non-clustered index; and all I get isdefinitions, not when to use one or both. Can you please tell me how I canlearn this, or would you be able to give me some general steps to do this?

Thank you



Clustered indexes should be used always. You can read some recommendations about it in here: http://www.scarydba.com/2011/04/04/sql-universityrecommendations-for-a-clustered-index/ . (Be sure to read the links in the conclusion)
Be careful when designing them as they're the base for performance tuning and other features.
Non-clustered indexes are used as an additional performance enhancement to retrieve data (or validate constraints). In my opinion, you should never have a non-clustered index without a clustered index. If you understand how each index works, you'll find it easier to understand when to use them.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
itmasterw 60042
itmasterw 60042
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1081 Visits: 305
Luis Cazares - Thursday, August 3, 2017 9:45 AM
itmasterw 60042 - Thursday, August 3, 2017 9:23 AM

Hi,

I have been looking all over the net and in books to findwhen to use a clustered and/or non-clustered index; and all I get isdefinitions, not when to use one or both. Can you please tell me how I canlearn this, or would you be able to give me some general steps to do this?

Thank you



Clustered indexes should be used always. You can read some recommendations about it in here: http://www.scarydba.com/2011/04/04/sql-universityrecommendations-for-a-clustered-index/ . (Be sure to read the links in the conclusion)
Be careful when designing them as they're the base for performance tuning and other features.
Non-clustered indexes are used as an additional performance enhancement to retrieve data (or validate constraints). In my opinion, you should never have a non-clustered index without a clustered index. If you understand how each index works, you'll find it easier to understand when to use them.


Okay thanks I will look at this
Thank you
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)SSC Guru (148K reputation)

Group: General Forum Members
Points: 148860 Visits: 22100
This is also a good place to start.
http://www.sqlinthewild.co.za/index.php/2011/11/11/sql-university-advanced-indexing-indexing-strategies/


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search