Checkpoint and its types - SQL Server
Checkpoint is a mechanism in SQL Server that writes all the modified pages from the buffer cache to disk. This process ensures that all the committed data is written to disk and the transaction log is truncated. In other words, a checkpoint is a point in time where the changes made to the database are permanently saved to disk.
There are four types of checkpoints in SQL Server:
Automatic Checkpoint: This is the default type of checkpoint in SQL Server, and it is triggered automatically by the server when certain conditions are met. These conditions include the size of the log file and the number of transactions. The frequency of automatic checkpoints can be configured in the database properties.
Indirect Checkpoint: This type of checkpoint is similar to automatic checkpoint, but it is triggered by the checkpoint background task instead of by a user or application. Indirect checkpoint is designed to reduce the overhead of writing to the transaction log by spreading the checkpoint activity over a period of time.
Manual Checkpoint: This type of checkpoint is initiated manually by a user or application. A manual checkpoint can be useful in scenarios where you need to force a checkpoint to ensure that all changes are written to disk immediately. You can use the T-SQL CHECKPOINT statement to initiate a manual checkpoint.
Internal Checkpoint: This type of checkpoint is triggered automatically by SQL Server during certain operations, such as when a database is detached or when a database snapshot is created. Internal checkpoints are designed to ensure that all changes are written to disk before the operation completes.
Here is an example of using the T-SQL CHECKPOINT statement to initiate a manual checkpoint:
USE YourDatabase
GO
CHECKPOINT
Comments
Post a Comment