How to view size of clustered index for a given table?

All we need is an easy explanation of the problem, so here it is.

Inherited the following audit table:

Table UserActions

AppID int
ActionTime datetime
Action varchar(25)
UserID int
Description text

Clustering key is on AppID, ActionTime, Action columns.
RowCount = appx 1 billion

How do I view the size of this particular clustered index in total and per row?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You can use the system stored procedure sp_spaceused to get the size of the Table which is going to be the size of your clustered index since the clustered index is the logical storage of the Table itself.

Example syntax: EXEC sp_spaceused 'UserActions';

Specifically you’d want to look at the data column of the result set since that will tell you the total size of the Table itself which is the clustered index size. (The index_size column is the total space consumed by all indexes, so could give different results depending on if you’re using other indexes such as nonclustered indexes too.)

The clustered index size per row is going to vary on each row (dependent on if you have varying sized data types or nullable columns), but you can get an average per row by dividing that data column by the rows column that the above procedure returns.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply