Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Table Space Query - data and index size

Posted on 2010-09-20
8
Medium Priority
?
703 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 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 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33715562
is that a question or a affirmation?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Viewers will learn how the fundamental information of how to create a table.
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.

885 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