-1

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?

0

1 Answer 1

0

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.

2
  • 1
    FYI, sp_spaceused is all lower-case. That matters with a case-sensitive instance collation.
    – Dan Guzman
    Apr 11, 2021 at 15:26
  • @DanGuzman True, I think it's silly Microsoft mixes naming conventions across their own products. I prefer to use something more standard when referencing them. Unfortunately you're right that this is a case that could matter since you normally run sp_spaceused in a user database which could have a case sensitive collation itself. I updated my answer accordingly, thanks.
    – J.D.
    Apr 11, 2021 at 16:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.