简体   繁体   English

SQL Server 数据库事务文件的“已用日志空间百分比”非常低

[英]Very Low "Used Log Space Percentage" for SQL Server database transaction file

Prologue序幕

I have always read/observed that we should not shrink database file as they tend to grow back.我一直读/观察到我们不应该缩小数据库文件,因为它们往往会重新增长。 There will be a performance penalty when DB will try to grow these files if there is not enough space already.如果已经没有足够的空间,DB 将尝试增加这些文件时,将会有性能损失。

Situation情况

When I am executing following query for few of my databases -当我对我的几个数据库执行以下查询时 -

select * from sys.dm_db_log_space_usage

Some of my databases are taking around 20 GB space.我的一些数据库占用了大约 20 GB 的空间。 Catch is column used_log_space_in_percent is showing values between .1 to 10 %. Catch 列 used_log_space_in_percent 显示的值介于 0.1 到 10 % 之间。 If I shrink these databases I can actually gain around 100 GB space immediately.如果我缩小这些数据库,我实际上可以立即获得大约 100 GB 的空间。 Also please note that LogReuseWaitDesc is "nothing" for some of DBs if not all.另请注意,LogReuseWaitDesc 对于某些数据库(如果不是全部)来说是“无”的。

Due to some reason, transaction log backups are not possible in near future.由于某种原因,事务日志备份在不久的将来是不可能的。 (Convincing in progress) (说服正在进行中)

It will be really helpful if you can provide recommendations as well as reasoning in such cases whether its a good idea to shrink files or not.如果您可以在这种情况下提供建议和推理,无论是否缩小文件是一个好主意,这将非常有帮助。

If you are taking time to think about this, THANK YOU!如果您正在花时间考虑这个问题,谢谢!

ldf files grow if you don't get backup, as soon as you create backup, SQL Server truncates log file.如果没有备份,ldf 文件会增长,一旦创建备份,SQL Server 就会截断日志文件。 Shrinking log files is not a good idea unless you have a backup.除非您有备份,否则缩小日志文件不是一个好主意。 Please read the followings :请阅读以下内容:

https://www.sqlshack.com/sql-server-transaction-log-backup-truncate-and-shrink-operations/ https://www.sqlshack.com/sql-server-transaction-log-backup-truncate-and-shrink-operations/

https://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/ https://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM