Running SQL Server 2012 standard, using both replication data and log shipping. Transaction log backups are created every few minutes.
This question is NOT about the amount of space reported by the file system.
We have a log table with four VARCHAR(max) columns. The table currently holds roughly 180 GB of data. The table grows at a rate of roughly 10 GB per month.
In an attempt to free up space for future growth, I recently deleted (in chunks over a 36 hour period) close to 30% of the data.
Based on the size of the table and the number of rows being removed, I expected the size of the table to be reduced by roughly 55-60 GB. I verified this by taking a sample and calculating the average row size, and then multiplying that by the number of rows to be removed. However, after finishing the delete, the table size has not changed.
While I am not looking to shrink the size of the .mdf file, I did check to see if the database had any free space that could be shrunk, but there is 0% free space.
So - I am confused. I've verified the data that I deleted from the table is no longer there. I even compared it against a backup to get a before & after. The number of rows in the database has changed, but the data space for the table has not decreased.
My questions then are:
1) Why did deleting data from the table not reduce the size of the table?
2) What can I do to actually reduce the size of the table?
EDIT:
- I am determining the space used by the table by calling sp_spaceused 'tablename'.
- I have used dbcc updateusage (0, tablename) prior to calling sp_spaceused.
- I am NOT trying to free up disk space - although an analysis indicates that there is 0% space available to be reclaimed.
- I have run an index reorganize with ( LOB_COMPACTION = ON ). Fragmentation is below 1%.
- The table is not a heap. Table definition below.
CREATE TABLE [dbo].[LARGE_LOG_TABLE]( [ID] [varchar](36) NOT NULL, [DOC_ID] [varchar](36) NOT NULL, [REQUEST_DATA] [varchar](max) NULL, [REQUEST_DATA_XSLT] [varchar](max) NULL, [RESPONSE_DATA] [varchar](max) NULL, [RESPONSE_DATA_XSLT] [varchar](max) NULL, [ACTIVE_FLAG] [varchar](1) NULL, [CREATED_BY] [varchar](100) NULL, [DATE_CREATED] [datetime] NULL CONSTRAINT [DF_LARGE_LOG_TABLE_CREATE_DT] DEFAULT (getdate()), [USER_LAST_UPDATED] [varchar](100) NULL, [DATE_LAST_UPDATED] [datetime] NULL CONSTRAINT [DF_LARGE_LOG_TABLE_LAST_DT] DEFAULT (getdate()), CONSTRAINT [PK_LARGE_LOG_TABLE] PRIMARY KEY CLUSTERED ( [ID] ASC ) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
EDIT 2:
SELECT * FROM sys.dm_db_index_physical_stats (db_id(), OBJECT_ID('database..LARGE_LOG_TABLE'), default, default, default)
EDIT 3:
The answers provided to the question at Delete query does not appear to open space on the SQL Server refer to freeing up space on disk / shrinking the physical size of the database. This question refers to removing rows containing LOB data and yet the database (internally) shows the LOB data has not been removed. We removed 600000 rows of data, but the space used on the table level (not the file system level) was only reduced by a few bytes - not the expected 60 GB. This question is about removing the LOB data.