SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Identify Large Tables


Identify Large Tables

Author
Message
Jesse McLain
Jesse McLain
Old Hand
Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)

Group: General Forum Members
Points: 359 Visits: 567
Comments posted to this topic are about the item Identify Large Tables

Jesse McLain
jesse@jessemclain.com
www.jessemclain.com
www.jessesql.blogspot.com
Doug S.
Doug S.
SSC Veteran
SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)

Group: General Forum Members
Points: 241 Visits: 331
Jessie, thanks very much for this, but I found something rather interesting, perhaps you can explain.

The query identified a table with row count = 154 and phys_size_KB = 26760. However, when I selected all rows I got a count of 202 is this because the statistics are out of date?

This table has a high unused allocation of 99%. I calculated this based on unused/reserved. I just ran a shrink on the database and it does not seem to help. Can you explain this?

Thanks



Doug
Doug S.
Doug S.
SSC Veteran
SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)SSC Veteran (241 reputation)

Group: General Forum Members
Points: 241 Visits: 331
Jessie, I did some searching and found that you should add a param to the sp_spaceUsed proc. This will give you a more accurate value.


EXEC sp_spaceused @User_Table_Name,'true'

I also used this to get the unused KB's for each table

Unused_KB = CONVERT(int, LEFT([unused], PATINDEX('% KB', [unused]) - 1))

Thanks again.



Doug
Jesse McLain
Jesse McLain
Old Hand
Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)Old Hand (359 reputation)

Group: General Forum Members
Points: 359 Visits: 567
Doug, thanks for the responses. I updated the code by adding the 'TRUE' parameter to the sp_spaceused call (and gave you credit for that - I submitted the updated version and it should be published soon). I noticed that it slowed down performance the first time it ran, and then ran instantaneously on subsequent executions.

Jesse McLain
jesse@jessemclain.com
www.jessemclain.com
www.jessesql.blogspot.com
WILLIAM MITCHELL
WILLIAM MITCHELL
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2104 Visits: 3057
here is another way to do this without a cursor

http://www.wvmitchell.com/tips/SQL_table_sizes.htm
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13606 Visits: 885
Thanks for the script.
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