473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sp_spaceused reports over 40 GB unused for a table

I have a large table that I recently purged a year of data from.
However, the table size in sp_spaceused hasn't decreased as much as I
would expect. (there are no text or large object columns on this
table, BTW) Running sp_spaceused on the table shows the following.

rows reserved data index size unused
TABLE_NAME 23470880 67790808 KB 18116312 KB 3211616 KB 46462880 KB

I ran a dbcc indexdefrag on all indexes on the table last night,
including the clustered index, and I'm still seeing pretty much the
same amount of space reported as unused.

The one thing that I haven't done yet is to run the sp_spaceused on
this table with the @updateusage flag set to true as I need to do this
afterhours to reduce contention. I will attempt this tonight and
report on the results.

Here's DBCC SHOWCONTIG OUTPUT for the table:
DBCC SHOWCONTIG scanning 'TABLE_NAME' table...
Table: 'TABLE_NAME' (917578307); index ID: 1, database ID: 7
TABLE level scan performed.
- Pages Scanned................................: 2264447
- Extents Scanned..............................: 285484
- Extent Switches..............................: 287092
- Avg. Pages per Extent........................: 7.9
- Scan Density [Best Count:Actual Count].......: 98.59%
[283056:287093]
- Logical Scan Fragmentation ..................: 0.04%
- Extent Scan Fragmentation ...................: 3.19%
- Avg. Bytes Free per Page.....................: 2418.9
- Avg. Page Density (full).....................: 70.12%
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.

Looking through the history of the group, the one thing that seems to
remedy this problem consistantly is to bcp out all the data, trunc the
table and bcp all the data back in. This is not really a possibility
for me due to the size of the table and the availability expectations
of my customers. Is there anything that I forgot to check? Do you
think that it's just a matter of incorrect statistics in sp_spaceused?

Thanks in advance:
Matt
Jul 20 '05 #1
4 7042
Try running sp_spaceused with the true parameter. For example:
sp_spaceused TABLE_NAME, true

Hope this helps,
Gert-Jan
spilich wrote:

I have a large table that I recently purged a year of data from.
However, the table size in sp_spaceused hasn't decreased as much as I
would expect. (there are no text or large object columns on this
table, BTW) Running sp_spaceused on the table shows the following.

rows reserved data index size unused
TABLE_NAME 23470880 67790808 KB 18116312 KB 3211616 KB 46462880 KB

I ran a dbcc indexdefrag on all indexes on the table last night,
including the clustered index, and I'm still seeing pretty much the
same amount of space reported as unused.

The one thing that I haven't done yet is to run the sp_spaceused on
this table with the @updateusage flag set to true as I need to do this
afterhours to reduce contention. I will attempt this tonight and
report on the results.

Here's DBCC SHOWCONTIG OUTPUT for the table:
DBCC SHOWCONTIG scanning 'TABLE_NAME' table...
Table: 'TABLE_NAME' (917578307); index ID: 1, database ID: 7
TABLE level scan performed.
- Pages Scanned................................: 2264447
- Extents Scanned..............................: 285484
- Extent Switches..............................: 287092
- Avg. Pages per Extent........................: 7.9
- Scan Density [Best Count:Actual Count].......: 98.59%
[283056:287093]
- Logical Scan Fragmentation ..................: 0.04%
- Extent Scan Fragmentation ...................: 3.19%
- Avg. Bytes Free per Page.....................: 2418.9
- Avg. Page Density (full).....................: 70.12%
DBCC execution completed. If DBCC printed error messages, contact your
system administrator.

Looking through the history of the group, the one thing that seems to
remedy this problem consistantly is to bcp out all the data, trunc the
table and bcp all the data back in. This is not really a possibility
for me due to the size of the table and the availability expectations
of my customers. Is there anything that I forgot to check? Do you
think that it's just a matter of incorrect statistics in sp_spaceused?

Thanks in advance:
Matt


--
(Please reply only to the newsgroup)
Jul 20 '05 #2
> I have a large table that I recently purged a year of data from.
However, the table size in sp_spaceused hasn't decreased as much as I
would expect. (there are no text or large object columns on this
table, BTW) Running sp_spaceused on the table shows the following.

Hi Matt,

I had a similar situation. I inherited a database with a lot of
unused space. It turns out the tables had non-clustered indexes but
no clustered index. When I changed one of the NC index to a clustered
index, all of the unused space went away.
Jul 20 '05 #3
Sorry, I missed the part where you mentioned you already had a
clustered index. Did you try DBCC Shrinkfile?
Jul 20 '05 #4
I ran sp_spaceused with the @updateusage flag set to true and that
fixed the output from sp_spaceused to be what I expected. Thanks for
the suggestions. Does anyone run this on a scheduled basis to keep
stats up to date? If so, how often?

Thanks
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: A.M. de Jong | last post by:
Hi, In our environment sp-spaceused returns: Allocated: 500 Unallocated: -100 Enterprise Database Taskpad shows that our total database size = 400 MB (320 used; 80 unused) Windows...
5
by: Brad Tobin | last post by:
On a production database, there is a 2GB database, when I run sp_spaceused it indicates a very high quanity of unused space. The database has been shrunk & free space sent to the OS. Why is this...
6
by: Robin Tucker | last post by:
I want to look at the size of the current database, so I can create a new one if it gets too big (we are working around the 2gb MSDE limit for our customers). I would like to do something like...
1
by: Hennie de Nooijer | last post by:
Hi I'm executing SP_SpaceUsed in a stored procedure like this : Exec ('SP_SpaceUsed '+ @table) This works great but when i want to execute it for a table in a other database i'm running in...
2
by: Jonathan LaRosa | last post by:
Hi all - I'm wondering if anyone has (or knows of) a tool that will allow me to search through VB code, tables, queries, reports, forms, and other objects, for references to all other types of...
4
by: Mike Thomas | last post by:
Access 2000 - Is there a 3rd party tool available, or perhaps some method built into Access 2000, which could isolate unused Access reports, queries, forms, etc? I have a 5 year old app which...
2
by: Russell Smith | last post by:
Postgresql 7.4.5 The following VACUUMs were run within a couple of minutes of each other completing. This table concerned is a table that has not been changed in a long time. (a month) There...
12
by: zacks | last post by:
Suddenly, in a VB2005 project I am working on, several variables show up in the list of warnings are being unused local variables. But they all are. Several of them are the ex variable used in a...
6
by: nickvans | last post by:
Hi all, I have a table called tblRecords that has "DashNum" as its primary key. The lowest value of this table is 116 and the highest value is 269, though there are some missing values. It is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.