Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««34567»»

How to free table space Expand / Collapse
Author
Message
Posted Tuesday, September 28, 2010 4:41 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, February 6, 2014 3:51 PM
Points: 180, Visits: 317
Did you try DBCC CleanTable out of curiousity?
Post #994865
Posted Tuesday, September 28, 2010 4:45 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 7:33 AM
Points: 21,620, Visits: 15,276
Whisper9999 (9/28/2010)
Did you try DBCC CleanTable out of curiousity?


He said he did - early on in the thread




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #994866
Posted Tuesday, September 28, 2010 5:28 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, February 6, 2014 3:51 PM
Points: 180, Visits: 317
Oops!
Post #994874
Posted Wednesday, September 29, 2010 6:59 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 1:20 PM
Points: 30, Visits: 49
Yes, I did DBCC CleanTable. Also, in my earlier results for DBCC SHOWCONTIG the ForwardedRecords=0 as any other field except ScanDensity=100.

I'll try to contact MS and let you know.
Post #995169
Posted Friday, October 1, 2010 9:50 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 9:36 AM
Points: 340, Visits: 406
If the table has < 2000 rows, then you probably wont notice much performance impact anyway while you drop/recreate indexes; that should take care of it.
Post #996790
Posted Thursday, October 21, 2010 12:51 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 1:20 PM
Points: 30, Visits: 49
After working with Microsoft the workaround was found:

There is a known issue where on a database having a LOB data in it, the SHRINK operation will only shrinks one empty LOB extent at a time. This is by design. And hence we may have to shrink multiple times to release the space to operating system. This behavior is because we do not deallocate the LOB pages; we save them for the next time we may need to insert LOB data. In certain cases, these allocated but empty LOB pages may accumulate. Again, this is by design.

Also When the LOB value to be inserted is larger than one page, we break it up into page-size fragments. And when we insert a page-size fragment, we don't search the existing LOB pages for free space; we instead just allocate a new page. This is an optimization: in the typical case, the free space fragments on the existing pages are all smaller than a page. Since we need a whole page of free space, we might as well skip the search and just allocate a new page.

NOTE: This behavior is by design and have been reported as a known issue.

Considering the above know behavior of SQL , which is by design the work around to release the empty LOB pages is as follows:
Use DBCC CLEANTABLE('databasename', 'tablename') to deallocate all the empty extents.

NOTE: The recommended option to delete all rows of a table is to use TRUNCATE option. Truncate has advantage over the Delete operation as I had mentioned in the previous email.

On your production database backup which I have restored at my end, when I ran the DBCC CLEANTABLE command. The sp_spaceused output after following the workaround was as follows:
Please run DBCC UPDATEUSAGE query on the table before you run SP_SPACEUSED query. Please refer link for more details: http://msdn.microsoft.com/en-us/library/ms188414(v=SQL.90).aspx

ADDITIONAL INFORMATION
• Pages and Extents
http://msdn.microsoft.com/en-us/library/ms190969(v=SQL.90).aspx
• Managing Extent Allocations and Free Space
http://msdn.microsoft.com/en-us/library/ms175195(v=SQL.90).aspx
• Managing Space Used by Objects
http://msdn.microsoft.com/en-us/library/ms187501(v=SQL.90).aspx

Post #1008735
Posted Friday, October 22, 2010 9:02 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, November 12, 2010 9:30 AM
Points: 37, Visits: 82
Did you try

Truncate table mytable
Post #1009269
Posted Friday, October 22, 2010 11:18 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 1:20 PM
Points: 30, Visits: 49
Yujie Fu (10/22/2010)
Did you try

Truncate table mytable


Yes, it released a table space but in production we did DELELE and stuck with the issue.
Post #1009380
Posted Saturday, October 23, 2010 1:52 PM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, June 21, 2013 9:07 PM
Points: 43, Visits: 317
Miksh, I am trying to understand this better, why was dropping and recreating the table not a desirable solution that you left as a "last resort"? I ask because we drop and recreate tables all the time, it causes no problem.
Post #1009642
Posted Monday, October 25, 2010 12:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 11, 2014 8:57 AM
Points: 184, Visits: 345
Hi,

Did you run "sp_spaceused @updateusage= 'true'"? Hope it fixes.

Alternately, pl try below;

Create a filegroup and aleter table to move to the new file group.
Then again move the table to the original filegroup and remove the temporary file group you created.
This long process is because you do not intend to drop/create an empty table.

I have noticed such problem in SQL 2000 where ntext data type existed and it did not releases the space from table. But the scene was different there as the space were shown in "unused space" which is not the case here. I had to follow the second approach which worked for me.
Post #1009806
« Prev Topic | Next Topic »

Add to briefcase «««34567»»

Permissions Expand / Collapse