Solved

Table Space Query - data and index size

Posted on 2010-09-20
8
670 Views
Last Modified: 2012-08-13
Hi All,

I have a n SQL Server 2000 database which has data imported each night into it.

The import has been failing for the past few nights so I am investigating as to why.

Now I have noticed that when I use the SPROC sp_spaceused to check the tables for size, I have 2 tables that currently contain 0 rows but the space used shows as:

Table 1
Data: 109264 KB
index_size: 11360 KB

Table 2
Data: 8988288 KB
index_size: 28880 KB

Both tables have primary keys and auto increment set and each night these tables are truncated before new data is inserted. But at the moment these tables are empty.

Can anyone advise why there would be so much data still attached to these tables even though there isn't any rows?

Thanks,

Rit
0
Comment
Question by:rito1
  • 4
  • 2
  • 2
8 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 33715384
is there a clustered index on the table?
if not, that might explain why the "reserved" space for the table is not released...
0
 
LVL 1

Author Comment

by:rito1
ID: 33715425
The index is clustered.?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33715562
is that a question or a affirmation?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 1

Author Comment

by:rito1
ID: 33715655
Hi angelIII,

Sorry just confused still... my tables have a clustered index on the primary key. So I am still looking into as to why the data still appears so big when there is physically no data in it.

Thanks for your help.

Rit
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 33715753
Instead of truncating the table, I'd suggest recreating them then inserting...
0
 
LVL 23

Assisted Solution

by:Racim BOUDJAKDJI
Racim BOUDJAKDJI earned 250 total points
ID: 33715771
Also please activate instant file initialization.  SQL Server space allocation/deallocation can be quite tricky...instant file initialization makes the process less painful.  eventually think of rebuilding the index (dbcc reindex) at the end of the import...
0
 
LVL 1

Author Comment

by:rito1
ID: 33715794
Hi Both,

I have just appended True at the end of my sp_spaceused SPROC and it shows the real statistic rather than a cached version... these stats look a lot better. Thanks for you help anyway.

Rit
0
 
LVL 1

Author Comment

by:rito1
ID: 33715811
Hi,

I just tried to award the points but it seems to have tried to close the question.. is this correct?

Rit
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Slow Connectivity over ODBC 8 35
stored procedures times out after 2 hours in sql server 2014 16 37
VB.net and sql server 4 35
Tsql query 6 22
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question