Writes all dirty pages for the current database to disk. Dirty pages are data pages that have been entered into the buffer cache and modified, but not yet written to disk. Checkpoints save time during a later recovery by creating a point at which all dirty pages are guaranteed to have been written to disk.
For performance reasons, the Database Engine performs modifications to database pages in memory and does not write the page to disk after every change. However, periodically the Database Engine needs to perform a checkpoint to write these dirty pages to disk. Writing dirty pages to disk creates a known good point from which the Database Engine can start applying changes contained in the log during recovery after an unexpected shutdown or crash
Syntex: CHECKPOINT [ checkpoint_duration* ]
*checkpoint_duration is the amount of time, in seconds, for the checkpoint to complete. When checkpoint_duration is specified, the SQL Server Database Engine attempts to perform the checkpoint within the requested duration. The checkpoint_duration must be an expression of type int, and must be greater than zero. When this parameter is omitted, SQL Server Database Engine automatically adjusts the checkpoint duration to minimize the performance impact on database applications.
Events That Cause Checkpoints
Before a database backup, the Database Engine automatically performs a checkpoint so that all changes to the database pages are contained in the backup. In addition, checkpoints occur automatically when either of the following conditions occur:
- The active portion of the log exceeds the size that the server could recover in the amount of time specified in the recovery intervalserver configuration option.
- The log becomes 70 percent full, and the database is in log-truncate mode.
A database is in log truncate mode when both these conditions are TRUE: the database is using the Simple recovery model, and, after execution of the last BACKUP DATABASE statement that referenced the database, one of the following events occurs:
- A minimally logged operation is performed in the database, such as a minimally logged bulk copy operation or a minimally logged WRITETEXT statement is executed.
- An ALTER DATABASE statement is executed that adds or deletes a file in the database.
Also, stopping a server issues a checkpoint in each database on the server. The following methods of stopping SQL Server perform checkpoints for each database:
- Using SQL Server Configuration Manager.
- Using SQL Server Management Studio.
- Using the SHUTDOWN statement.( The SHUTDOWN WITH NOWAIT statement shuts down SQL Server without executing a checkpoint in each database. This may cause the subsequent restart to take a longer time than usual to recover the databases on the server )
- Using the net stop mssqlserver command in a command-prompt window.
- Using Services in Control Panel, selecting mssqlserver, and clicking Stop.
- Bringing an instance offline in a cluster.
Permissions: CHECKPOINT permissions default to members of the sysadmin fixed server role and the db_owner and db_backupoperatorfixed database roles, and are not transferable.
|
No comments:
Post a Comment