Effects of Data Modifications
From SQLServerPedia
|
See Also: Main_Page - Database Administration - Database Design - Indexing How Inserts Affect IndexesWhen a row is inserted into a table, rows are also added to all non-clustered indexes. If a table has a clustered index, new rows are inserted according to the order of the clustered index. For instance, if the clustered key is last_name, then a new row with a last name of "Brown" will be inserted on the data page containing other last names beginning with the letter "B". If a table does not have a clustered index, then SQL Server checks Page Free Space (PFS) pages to find a data page that has free space available. Therefore, in a heap a row with a last name of "Brown" could be inserted on the same page as the last name of "Smith". How Deletes Affect IndexesWhen a row is removed from a table, corresponding rows are also removed from all non-clustered indexes. The index from which a row was removed will have some free space on the page where the row used to reside. If the deleted rows are not replaced with new rows, the index becomes fragmented. How Updates Affect IndexesWhen a row is updated, changes that have to occur in indexes depend on the columns that get changed. If the clustered index key is updated, then the row might have to be moved from one page to another. For example, if we update the last name of "Brown" to "Paulsen" and the clustered index is on the last_name, then the row will have to be moved to the page containing last names that begin with "P". Non-clustered indexes will be updated if the non-clustered keys are updated or if clustered index's key value is updated. On the other hand, if we update the first_name column, and there is no index containing this column then none of the indexes have to be updated. So the net effect of data modifications is adding overhead to tables with indexes. If you have appropriate indexes they can actually speed up data modifications. However, if you have numerous indexes on tables with constant data changes your performance may suffer. More SQLServerPedia Articles on IndexesHow SQL Server Indexes Work
Types of Indexes in SQL Server
Best Practices on How to Design Database Indexes
Maintaining Indexes for Top PerformanceIndexes need regular maintenance in order to perform well.
|