[SQL Server]大容量日志恢复模式bulk_logged recovery model

The bulk-logged recovery model minimally logs bulk operations, although fully logging other transactions. The bulk-logged recovery model protects against media failure and, for bulk operations(bcp,BULK INSERT,SELECT INTO), provides the best performance and least log space usage.

The bulk-logged recovery model increases the risk of data loss for these bulk-copy operations, because bulk logging operations prevents recapturing changes on a transaction-by-transaction basis. If a log backup contains any bulk-logged operations, you cannot restore to a point-in-time within that log backup; you can restore only the whole log backup.

 Bulk Changed Map (BCM)  tracks the extents that have been modified by bulk logged operations since the last BACKUP LOG statement.
If using the bulk-logged recovery model, only details of the modified data pages are logged, allowing for better performance.

Tail Log backup
If your database is using the bulk-logged recovery model, and the transaction log contains minimally logged transactions, the data files which contain the modified pages must also be available. If those data files are unavailable, you will not be able to back up the tail of the transaction log. This is another point to consider when using the bulk-logged recovery model.

However, please note that the situation with the bulk-logged recovery model is identical to the full recovery model if no minimally logged transactions are created in the database


大容量日志恢复模式的工作原理

与完整恢复模式(完全记录所有事务)相比,大容量日志恢复模式只对大容量操作进行最小记录(尽管会完全记录其他事务)。大容量日志恢复模式保护大容量操作不受媒体故障的危害,提供最佳性能并占用最小日志空间。

但是,大容量日志恢复模式会增加这些大容量复制操作丢失数据的风险,因为大容量日志操作阻止再次捕获对每个事务逐一所做的更改。如果日志备份包含大容量日志操作,则无法还原到该日志备份中的时点,而只能还原整个日志备份。

在大容量日志恢复模式下,如果日志备份覆盖了任何大容量操作,则日志备份包含由大容量操作所更改的日志记录和数据页。这对于捕获大容量日志操作的结果至关重要。合并的数据区可使日志备份变得非常庞大。此外,备份日志需要访问包含大容量日志事务的数据文件。如果无法访问任何受影响的数据库文件,则事务日志将无法备份,并且在此日志中提交的所有操作都会丢失。

为跟踪数据页,日志备份操作依赖于位图页的大容量更改,位图页针对每个区包含一位。对于自上次日志备份后由大容量日志操作所更新的每个区,在位图中将每个位都设置为 1。数据区将复制到日志中,后跟日志数据。下图显示了日志备份的构造方式。

[SQL Server]大容量日志恢复模式bulk_logged recovery model_第1张图片


重要提示:
在完整或大容量日志恢复模式下,如果没有其他因素使日志记录保持为活动状态,则到进行第一次完整备份时,自动检查点才会截断事务日志的未使用部分。第一次完整备份后,截断要求备份事务日志。有关截断延迟因素的信息,请参阅可能延迟日志截断的因素。

你可能感兴趣的:(sql,server,database,insert,performance,logging,transactions)