Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Disk Usage by Top Tables


Disk Usage by Top Tables

Author
Message
ben.brugman
ben.brugman
SSC-Addicted
SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)

Group: General Forum Members
Points: 465 Visits: 2220
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 ?
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
use varchar(16) instead of bigint

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Sean Pearce
Sean Pearce
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1170 Visits: 3432
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
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47181 Visits: 44356
Far easier way, just query sys.dm_db_partition_stats.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


zimoch2
zimoch2
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
ben.brugman
ben.brugman
SSC-Addicted
SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)SSC-Addicted (465 reputation)

Group: General Forum Members
Points: 465 Visits: 2220
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search