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


What Maintenance task am I missing?


What Maintenance task am I missing?

Author
Message
Damian
Damian
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4936 Visits: 1310
Hello

I have a few tables that seem to be using an excessively high amount of disk space
They also return results inefficiently

An example:

I have a table called E_DIM_POLICY
This has around 450k rows in it
It has 8 columns all varchar(255) datatypes

If I look at the datasize (sp_spaceused) it's coming in at 11.8GB!

If I copy this table to another database, the size is (a more realistic) 176MB


Question is, why is it taking up so much space?

Also, am I missing something from my standard, fairly simplistic, maintenance activities
I have 2 maintenances plans
One that that verifies DB Integrity and Backs up DAILY
One that rebuilds indexes (handles indexes and statistics) WEEKLY


Thanks

Damian.

- Damian
GilaMonster
GilaMonster
SSC Guru
SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)

Group: General Forum Members
Points: 587602 Visits: 48014
What indexes does that table have?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Damian
Damian
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4936 Visits: 1310
In this instance, there are no indexes on the table

- Damian
GilaMonster
GilaMonster
SSC Guru
SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)

Group: General Forum Members
Points: 587602 Visits: 48014
Then that's your problem, not the maintenance. With no indexes at all, no clustered index, the table is a heap. Firstly index rebuilds won't touch heaps, second deletes don't deallocate empty pages unless the delete runs with a table lock. Hence you have a table that's mostly full of empty space.

I've seen an empty table (0 rows) that when read processed 600MB of pages.

At minimum put a clustered index on that, and every other table in your DB. Consider other indexes too.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Damian
Damian
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4936 Visits: 1310
Thanks for the advice Gail. I'll take a look at the indexes

- Damian
Damian
Damian
SSCarpal Tunnel
SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)SSCarpal Tunnel (4.9K reputation)

Group: General Forum Members
Points: 4936 Visits: 1310
Perfect

Added a clustered index
Rebuilt stats for that table
Looked at space used and it's what I would expect

Will look at other tables

Thanks

Damian.

- Damian
GilaMonster
GilaMonster
SSC Guru
SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)SSC Guru (587K reputation)

Group: General Forum Members
Points: 587602 Visits: 48014
You don't need to update statistics. A freshly built index will have up to date stats already.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


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