Add persisted log buffer to a database
Applies to: SQL Server
This topic describes how to add a persisted log buffer to a database in SQL Server 2019 (15.x) and above using Transact-SQL.
Requires ALTER permission on the database.
Configure persistent memory device (Linux)
To configure a persistent memory device in Linux.
Configure persistent memory device (Windows)
To configure a persistent memory device in Windows.
Add a persisted log buffer to a database
The following example adds a persisted log buffer.
ALTER DATABASE <MyDB> ADD LOG FILE ( NAME = <DAXlog>, FILENAME = '<Filepath to DAX Log File>', SIZE = 20MB );
ALTER DATABASE WideWorldImporters ADD LOG FILE ( NAME = wwi_log2, FILENAME = 'F:/SQLTLog/wwi_log2.pldf', SIZE = 20MB );
The log file on the DAX volume will be sized at 20 MB regardless of the size specified with the ADD FILE command.
The volume or mount the new log file is placed must be formatted with DAX enabled (NTFS) or mounted with the DAX option (XFS/EXT4).
Remove a persisted log buffer
To safely remove a persisted log buffer, the database must be placed in single user mode in order to drain the persisted log buffer.
The following example removes a persisted log buffer.
ALTER DATABASE <MyDB> SET SINGLE_USER; ALTER DATABASE <MyDB> REMOVE FILE <DAXlog>; ALTER DATABASE <MyDB> SET MULTI_USER;
ALTER DATABASE WideWorldImporters SET SINGLE_USER; ALTER DATABASE WideWorldImporters REMOVE FILE wwi_log2; ALTER DATABASE WideWorldImporters SET MULTI_USER;
Transparent Data Encryption (TDE) is not compatible with persisted log buffer.
Availability Groups can only use this feature on secondary replicas due to the requirement by the log reader agent for standard log writing semantics on the primary. However, the small log file must be created on all nodes (ideally on DAX volumes or mounts). In the event of a failover, the persisted log buffer path must exist, in order for the failover to be successful.
In cases where the path or file isn't present during an Availability Group failover event, or database startup, the database enters a
RECOVERY PENDING state until the issue is resolved.
Interoperability with other PMEM features
Back up and restore operations
Normal restore conditions apply. If persisted log buffer is restored to a DAX volume or mount, it will continue to function, otherwise it can be safely removed.