7

I have a large table which has a ton of unused space. I updated the table recently and NULLed out a varbinary (max) column that we didn't need. This has created a lot of unused space:

EXEC sp_spaceused N'dbo.ClientHistory';

enter image description here

The table only has a single clustered primary key index. I tried rebuilding it, but it didn't help.

ALTER INDEX PK_ClientHistory ON dbo.ClientHistory 
REBUILD WITH (FILLFACTOR = 95, SORT_IN_TEMPDB = ON);

I also tried updating statistics, which also didn't help.

UPDATE STATISTICS dbo.ClientHistory WITH FULLSCAN;

I've tried shrinking the database, which didn't help either.

DBCC SHRINKFILE (N'mydb_Data' , 0, TRUNCATEONLY)

The unused percentage remains at about 50%. What else can I try short of copying data into another table and then doing the renaming dance.

0

1 Answer 1

13

REBUILD doesn't do "LOB Compaction". You need

ALTER INDEX PK_ClientHistory ON dbo.ClientHistory
REORGANIZE WITH (LOB_COMPACTION = ON)
1
  • My god. You solved something that 5 LLMs couldn't. Although Grok did recognize the problem (e.g. LOB), but didn't tell me that it was possible to fix it. Bravo, sir! Commented 2 days ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.