Solved

Table Space Query - data and index size

Posted on 2010-09-20
8
661 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
 
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
[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now