1

After I delete huge amount of data from a SQL Server database table, the database size increased.

When I run sp_spaceused it shows me 2625.25 MB. It used to be ~ 1800.00 MB before I deleted from table.

Is there any specific reason it keeps growing even if I delete data?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158

2 Answers2

2

A temporary transaction log is often the reason for a notable increase of size after a huge delete.

It will eventually disappear on its own but you may remove the files if you need to reclaim the space.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
2

I'm assuming that you are using SQL Server (sp_spaceused). Deleting is logged, so your log file has grown.

See SQL Server 2008 log will not truncate on how to truncate your log (depending on your DB and recovery model), and then you can run

DBCC SHRINKFILE(N)

to reclaim lost space

Edit As per @Aaron, Truncating is also a logged operation. Answer corrected.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • TRUNCATE is also logged. Where do people learn these myths that TRUNCATE is not logged? – Aaron Bertrand Jun 02 '12 at 21:00
  • @Aaron Thanks for pointing this out. I believe I know where I picked up this misconception - the SQL 2000 and previous command 'BACKUP LOG DB WITH TRUNCATE_ONLY' probably fused my (and other's) synapses into associating 'truncate' with bypassing logging. – StuartLC Jun 03 '12 at 06:48
  • [Truncate has significantly less logging though](http://dba.stackexchange.com/a/7677/3690) – Martin Smith Jun 04 '12 at 09:56