This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one script to find the size of Indexes in SQL Server.
The first step for performance optimization is to measure the size of tables and indexes which helps you to find out more about fragmentation.
I have already shared a couple of articles on SQL Server Indexes like: find duplicate indexes, unused indexes and fragmentation of indexes.
You can also access these articles after below T-SQL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SELECT OBJECT_SCHEMA_NAME(i.OBJECT_ID) AS SchemaName ,OBJECT_NAME(i.OBJECT_ID) AS TableName ,i.name AS IndexName ,8 * SUM(au.used_pages) AS IndexSizeInKB FROM sys.indexes AS i JOIN sys.partitions AS p ON p.OBJECT_ID = i.OBJECT_ID AND p.index_id = i.index_id JOIN sys.allocation_units AS au ON au.container_id = p.partition_id GROUP BY i.OBJECT_ID ,i.index_id ,i.name ORDER BY OBJECT_NAME(i.OBJECT_ID),i.index_id |
Other related articles:
SQL Server: Script to find Index Average Fragmentation in Percentage
Leave a Reply