SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 
        
Home       Members    Calendar    Who's On


12»»

Deleting Large Tables Expand / Collapse
Author
Message
Posted Friday, November 06, 2009 11:12 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:48 PM
Points: 15, Visits: 21
Quick question, what is the best thing to do with a database to save space after after deleting large tables from it? Especially since the dbcc index defrag option is no longer supported in the sql server 2008. What about the database shrink option?
Post #815097
Posted Friday, November 06, 2009 11:27 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 11:29 PM
Points: 559, Visits: 464
What is the Size of the DB and space available? the reason for the question is, in case you need to add new Data into the database, then you should not shrink the DB, since the File would again autogrow which is has performance impact and should be avoided.

So before shrinking decide about this.


Regards,
Bru Medishetty
www.LearnSQLWithBru.com
Post #815107
Posted Friday, November 06, 2009 11:32 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:48 PM
Points: 15, Visits: 21
Its a bout 50 gigs and I don't plan on adding more data. I guess I just want to know how to get the space back because deleting a table doesn't guarantee that you have freed up space. Thanks for your input by the way
Post #815109
Posted Friday, November 06, 2009 11:34 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:28 AM
Points: 1,966, Visits: 3,360
Hi

In this case shrink seems to be the correct solution.

Greets
Flo



The more I learn, the more I know what I do not know

How to Post Data/Code to get the best Help"Numbers" or "Tally" Table
How to Post Performance Problems
Post #815110
Posted Friday, November 06, 2009 11:37 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:48 PM
Points: 15, Visits: 21
Thanks a lot. So what if I planned on adding more data to the database daily? What would be the best solution then?
Post #815115
Posted Friday, November 06, 2009 11:42 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 2:28 AM
Points: 1,966, Visits: 3,360
New data? Thought there will be no new data..

In this case take Bru Medishetty's advice. Do not shrink the database. Delete old data take backups of your database and log files to release file usage and add new data.

Greets
Flo



The more I learn, the more I know what I do not know

How to Post Data/Code to get the best Help"Numbers" or "Tally" Table
How to Post Performance Problems
Post #815116
Posted Friday, November 06, 2009 12:26 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:48 PM
Points: 15, Visits: 21
Thanks, I just wanted to know what would happen in the other scenario for future purposes. Thanks again guys !
Post #815137
Posted Saturday, November 07, 2009 3:18 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 3:09 PM
Points: 2,069, Visits: 2,039
I know I'm late to this party, but I have to say:

Only shrink if you absolutely must reclaim disk space.

Shrinking moves pages from the end of the physical files one at a time. Not only is that a slow (and fully logged) operation, but it is overwhelmingly likely that the moved pages will end up out-of-order as far as the object they belong to is concerned. So, shrinking is just about the best way to fragment data and indexes available. If you really really really can't avoid it, be sure to rebuild your indexes after shrinking. Bear in mind that rebuilding indexes (even if SORT_IN_TEMPDB is ON) will require workspace in the file...

Paul



The quality of the answers is directly proportional to the quality of the question.
Post #815371
Posted Sunday, November 08, 2009 12:30 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 1:39 PM
Points: 322, Visits: 568
johnsonchase7 (11/6/2009)
<snip> Especially since the dbcc index defrag option is no longer supported in the sql server 2008.</snip>


Note that it's just the dbcc index defrag syntax that has been removed. Index defragging is now performed using ALTER INDEX ... REORGANIZE.



Eddie Wuerch
MCT; MCTS (SQL-2005, SQLDev-2008, DBA-2008), MCITP (SQLDev-2005, DBA-2005, DBA-2008)
MCDBA, MCSD
sql@mirai-tech.com
Post #815595
Posted Monday, November 09, 2009 3:09 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 3:13 AM
Points: 202, Visits: 383
I'm curious whether truncating the table might not be a better idea here? If there are foreign key contraints that reference the table this won't work, of course, but then again the truncate option will reduce the usage of the transaction log (again, assuming that the user doesn't ever want to rollback the query!).

Random Technical Stuff
Post #815694
« Prev Topic | Next Topic »

12»»

Permissions Expand / Collapse