Skip to content
Advertisement

Retrieve the correct disk space usage of a columnstore index in MSSQL

I was trying to retrieve the exact amount of bytes required by a clustered columnstore index in MSSQL. Unfortunately I get different result from sp_spaceused compared to a simple query on sys.allocation_units.

Here the simple script:

Here the sp_spaceused result:

Then I try to get the amount of occupied pages querying directly sys.allocation_units using this query:

And of course the result is apparently exactly the half returned by sp_spaceused.

Can anyone help me to figure out what am I missing? Which is the correct way to get the exact table size in bytes?

Advertisement

Answer

This is the final query that returns the exact same size as the sp_spaceused do:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement