Home > DeveloperSection > Blogs > Indexes in SQL Server

Indexes in SQL Server


Database Database 
Ratings:
0 Comment(s)
 1709  View(s)
Rate this:

Indexes in SQL Server

Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quicker.
Indexes are of two types.

·         Clustered indexes

·         Non-clustered indexes.

When you create a clustered index on a table, all the rows in the table are stored in the order of the clustered index key. So, there can be only one clustered index per table. Non-clustered indexes have their own storage separate from the table data storage. Non-clustered indexes are stored as B-tree structures (so do clustered indexes), with the leaf level nodes having the index key and it's row locater. The row located could be the RID or the Clustered index key, depending up on the absence or presence of clustered index on the table.

If you create an index on each column of a table, it improves the query performance, as the query optimizer can choose from all the existing indexes to come up with an efficient execution plan. At the same time, data modification operations (such as INSERT, UPDATE, DELETE) will become slow, as every time data changes in the table, all the indexes need to be updated. Another disadvantage is that, indexes need disk space, the more indexes you have, more disk space is used.

Advantage of indexes

·         Searching for records

·         Sorting records

·         Grouping records

·         Maintain unique coloumn


Don't want to miss updates? Please click the below button!

Follow MindStick