Diskspace usage of DB
-
30-10-2019 - |
Question
I have a production database that's consuming a significant amount more disk space than it should be.
Using sp_spaceused (only the interesting tables), I get.
Table Name Reserved (KBs) Data (KBs) Index Size (KBs)
---------- -------------- ---------- ----------------
E 149600 142992 1136
H 184968 12104 162272
M 94104 29512 62480
T 25616 13544 9464
MH 16072 10640 5208
U 5399312 2984184 2414376
Total 5869672 3192976 2654936
However, the on disk size is a whopping 16 GB
database and 6 GB
log file.
The culprit is mainly Table U
. Most of the data is very static with just lots of UPDATE
to existing rows. Table U
is the ony with loads of data being added constantly, and being archived weekly.
Table U
's definition is,
[ID] INT NOT NULL,
[RD] DATETIME NOT NULL,
[UN] CHAR (7) NOT NULL,
[A] BIT NOT NULL,
[C] BIT NOT NULL,
[S] DATETIME NOT NULL,
[rowguid] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL
It receives about 5 million rows per week, and archives another 5 million rows per week.
It has not been partitioned / placed into separate file groups.
The system has been arround for approximatley 6 months, and I don't believe our DBA team have ever shrunk it / defragged it!
Questions
- Why is SQL using so much more disk space than sp_spaceused says?
- Is the churn responsible for most of this disk space issue?
- How should I use (SQL commands please) partitions and file groups to better optimise this churn?
No correct solution