Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Disk Usage by Top Tables Expand / Collapse
Author
Message
Posted Wednesday, October 17, 2012 5:59 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, December 14, 2014 3:41 PM
Points: 257, Visits: 1,225
Hello All,

The report Disk Usage by Top Table is very usefull.

What is the source of the numbers in this report ?
Or how can I get this report in a table ?



Now I use Excel as an intermediate and do some cutting an pasting.

Thanks for your time and attention,
Ben Brugman

(Did a google search on :
Disk Usage by top tables results in a table)

On
[url=http://database.ittoolbox.com/groups/technical-functional/sql-server-l/tables-sizes-in-a-db-4071428][/url]

I found:
CREATE TABLE #TableSizes (name sysname, rows varchar(16), 
reserved varchar(16), data varchar(16), index_size varchar(16),unused varchar(16))
INSERT #TableSizes
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
SELECT TOP (100) * FROM #TableSizes
ORDER BY DATA desc

But here the numbers can not be sorted.
(changing the declaration to bigint gives
Msg 8114, Level 16, State 1, Procedure sp_spaceused, Line 178
Error converting data type varchar to bigint.
)

Did a rebuild on that:
-- Create a tableSizes table which displays the same information as Disk Usage by Top Tables report.
-- Ben Brugman
-- 20121017
-- Part of the source comes from:
-- http://database.ittoolbox.com/groups/technical-functional/sql-server-l/tables-sizes-in-a-db-4071428

CREATE TABLE ##TableSizes (name sysname, rows varchar(16),
reserved varchar(16), data varchar(16), index_size varchar(16),unused varchar(16))
INSERT ##TableSizes
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"

update ##TableSizes set
Reserved = replace(reserved,'kb',''),
index_size = replace(reserved,'kb',''),
data = replace(reserved,'kb',''),
unused = replace(reserved,'kb','')

CREATE TABLE ##TableSizes2 (name sysname, rows bigint,
reserved bigint, data bigint, index_size bigint,unused bigint)
insert into ##TableSizes2 select * from ##TableSizes

SELECT TOP (1000) * FROM ##TableSizes2
ORDER BY reserved desc
drop table ##TableSizes
drop table ##TableSizes2

This is a bit cumbersome, I think that there is a more direct solution/call/script ?
Post #1373744
Posted Wednesday, October 17, 2012 6:02 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 2:16 AM
Points: 2,840, Visits: 3,983
use varchar(16) instead of bigint

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1373747
Posted Wednesday, October 17, 2012 6:09 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 1:37 AM
Points: 997, Visits: 3,089
Bhuvnesh (10/17/2012)
use varchar(16) instead of bigint

The OP cannot sort the result set using varchar, hence the bigint.




The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1373750
Posted Wednesday, October 17, 2012 8:11 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 6:44 AM
Points: 40,614, Visits: 37,079
Far easier way, just query sys.dm_db_partition_stats.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1373812
Posted Sunday, November 10, 2013 4:39 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 12, 2013 2:42 PM
Points: 1, Visits: 4
Hello,

I'm newbie in interpreting of Disk Usage by Top Tables report.

Could you give me some advice how to read it ?

What does it mean if table with big number of data have a very small Indexes ? Could it be a problem that I have not enough indexes for all columns ?

Example from my db:

Table Name # Records Reserved (KB) Data (KB) Indexes (KB) Unused (KB)
dbo.Materiales 515 011 583 592 258 488 324 912 192
dbo.TariffsContent 173 517 292 184 69 576 222 304 304
dbo.MaterialesBase 9 857 139 432 135 752 3 536 144
dbo.LanguageContent 216 112 113 752 70 984 42 704 64
dbo.Translation 251 771 95 960 57 088 38 712 160
dbo.Dibujos 753 90 712 90 512 96 104
dbo.DescripcionCampos 79 088 55 048 47 152 7 856 40
dbo.Escandallos 3 314 52 952 52 424 360 168
dbo.ContenidoTarifario 256 907 52 424 50 136 2 280 8
dbo.ContenidoOpciones 27 212 43 992 41 416 2 440 136
Open.SetsDescriptionsOptions 51 285 21 448 20 520 896 32
dbo.Reglas 33 892 18 248 18 080 128 40
Post #1512958
Posted Sunday, November 10, 2013 8:41 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, December 14, 2014 3:41 PM
Points: 257, Visits: 1,225
This is a rather old thread, so for this question it would have been better to start a new thread.

I use the numbers always as a rough indication;

Table Name         The tablename
Records The number of records in the table (from internal administration).
Reserved Total space for this table.
Data The space used for the data.
Indexes The space used for the indexes.
Unused The still unused space.

Adding up all reserved spaces from all tables should account for the size of the database.

As said all numbers should be taken a a rough indication.
In most circumstances the numbers are very accurate.

Ben
Post #1512966
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse