patternMinor
How much space is one row taking up
Viewed 0 times
spacemuchonehowrowtaking
Problem
I need to find out how much disk space a single row is taking up in a table. I can then use this as an approximate to work out how much disk space I can recover by removing old unneeded data. Would I have to combine all of the columns in a single
Or is there a better, more efficient way that I'm not aware of?
EDIT
I have just noticed that if a column has a
SELECT statement, like so?SELECT DATALENGTH([Id]) + DATALENGTH([Column1]) + DATALENGTH([Column2]) AS 'Size'
FROM [MyTable]Or is there a better, more efficient way that I'm not aware of?
EDIT
I have just noticed that if a column has a
NULL value, then I get NULL as the result.Solution
How much data do you have?
Personally, I'd do one of
The questions is complicated when you have
So, I'd do it empirically rather than by calculation...
Personally, I'd do one of
- try it on a test system and check "before" and "after"
- just remove unused data because by definition, it isn't needed
The questions is complicated when you have
- variable length data: how much of the field is used on average?
- page density (rows per page) may not increase therefore you save no space
- indexes duplicate a column value, so you have to count some ones twice
So, I'd do it empirically rather than by calculation...
Context
StackExchange Database Administrators Q#12470, answer score: 2
Revisions (0)
No revisions yet.