What are clustered index and non clustered index


With a clustered index the rows are stored physically on the disk in the same order as the index. There can therefore be only one clustered index.
With a non clustered index there is a second list that has pointers to the physical rows. You can have many non clustered indexes, although each new index will increase the time it takes to write new records.
It is generally faster to read from a clustered index if you want to get back all the columns. You do not have to go first to the index and then to the table.
Writing to a table with a clustered index can be slower, if there is a need to rearrange the data.
In other words,
A clustered index means you are telling the database to store close values actually close to one another on the disk. This has the benefit of rapid scan / retrieval of records falling into some range of clustered index values.


From Wikipedia :
database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of slower writes and increased storage space

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...