Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Effective Indexes


Published on

Effective Indexes for beginners

  • Be the first to comment

  • Be the first to like this

Effective Indexes

  1. 1. Effective Indexes For Beginners<br />
  2. 2. Performance is slow<br />Let’s add another index!<br />
  3. 3. Ineffective Indexes<br />Insert, Update and Delete operations will be slower if you have too many indexes on your table<br />Indexes are stored on the disk, the more indexes you have, the more disk space you use<br />
  4. 4. sys.dm_db_index_usage_stats<br />Counts of different types of index operations<br />Time each type of operation last performed.<br />Requires VIEW SERVER STATE permission<br />Counters reset to empty when SQL Server Service is restarted<br />If the database is detached or shutdown, all rows associated with that DB are removed<br />Information gathered is real-time<br />
  5. 5. sys.dm_db_index_usage_stats<br />
  6. 6. On to the code…<br />Pick a table and view its indexes<br />Take a look at the current usage <br />Run code that targets each index and see when the index was last used<br />Recheck the usage<br />View index usage for entire database<br />How to disable an index<br />How to enable an index<br />How to drop an index<br />
  7. 7. Demo...<br />
  8. 8. Conclusion<br />Use sys.dm_db_index_usage_stats DMV to easily identify real-time index usage stats<br />Identify indexes that are rarely or never used<br />Disable for a time before dropping<br />If disabled indexes aren’t missed – drop them to save disk space<br />
  9. 9. Resources<br />Click on the Word icon to the right to access the SQL code used in the practical element of this session. <br />Download AdventureWorks2008 DBs for free here:<br />BOL sys.dm_db_index_usage_stats information page:<br />Useful blog article on managing indexes at a more detailed level:<br />Blog:<br />Web:<br /><br />Email:<br />
  10. 10. Website:<br /><br />Mailing list:<br /><br />