Domanda

I've a sql server database sized 1677,25 MB. Here's my detailed DB size info:

DB Size:1677.25 MB
Unallocated space: 343.09 MB

Reserved: 24488 KB Data: 18560 KB Index size: 2632 KB Unused: 3296 KB Row Count: 74410

So, as you can see it's not that big DB. The issue is, logs.

Log file's size is: 1.311 GB

How can I clean the old logs? Ok maybe last 3 month's important but 1.3 GB is really an important size.

È stato utile?

Soluzione

First you need to understand, why your log file is this big. You can use this query for that:

SELECT name,log_reuse_wait_desc FROM sys.databases;

More information about the purpose of the log file and about how to interpret the results this query you can find here:

http://sqlity.net/en/556/t-sql-tuesday-25-%E2%80%93-sql-server-tips-tricks/

The most likely cause is, that the database is in "FULL" recovery mode. That means that SQL Server keeps all the log records until you create a log backup. Taking a full backup does not change this.

After you took the log backup, SQL Server can reuse the space in the log file. At that point you could also shrink the log file to a more appropriate size. If you do not need point in time recovery, you could switch the databas to simple recovery. That way SQL Server keeps the log records only as long as it needs them for transaction handling.

However, as the article above explains, there could be other reasons causing your problem too, like a forgotten replication setup. If you need further help on this, post the result of the above query.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top