Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 clustered and nonclustered index

Author  Topic 

funketekun
Constraint Violating Yak Guru

491 Posts

Posted - 2006-06-02 : 16:29:59
when do you use them?

i only know you use clustered when you have million of records. So once the table has been indexed, query statement is able to retrieve the recordset faster.

what about nonclustered?

Kristen
Test

22859 Posts

Posted - 2006-06-03 : 02:16:54
"i only know you use clustered when you have million of records"

Nope, that's not a criteria I would use.

A clustered index means the data itself is held "within" the index. Thus there can only be one per table. It is great for processing a range of records - because as you "next" through the records they are adjacent in the data file. Most commonly used for the Primary Key, although it doesn't have to be.

Non clustered indexes are therefore used for all the other indexes. They require two I/O's to get to the record - one to read the index record and a second to read the data record; this can mean that in order to "next" through the records whilst SQL is walking sequentially through the index it may be jumping around all over the data itself.

Kristen
Go to Top of Page

funketekun
Constraint Violating Yak Guru

491 Posts

Posted - 2006-06-03 : 14:25:26
so when do u use clustered and nonclustered.?"
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-06-03 : 15:01:53
Interview question?




CODO ERGO SUM
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-06-03 : 23:36:24
quote:
Originally posted by funketekun

so when do u use clustered and nonclustered.?"



Kristen gave you a reason.

we have trouble answering these types of questions because:

1. this is usually homework
2. if it isn't homework, it is an interview question
3. Books online contains this info
4. if you can't find info in BOL, then googling "clustered index sql server" will certainly work



-ec
Go to Top of Page
   

- Advertisement -