Wondering what the Checkpoint process in SQL server is? We can help you.
Checkpoints are the useful repositories of information and serve best for the recovery of SQL server databases.
When the SQL database server faces an unexpected shutdown or crash, the checkpoint creates a known good point from which the SQL Server Database Engine can start applying changes contained in the log during recovery.
Here at Bobcares, we handle SQL database servers of our customers as a part of our Server Management Services.
Today, we will discuss in detail the types of Checkpoint process in SQL server.
Types of Checkpoint process in SQL server
SQL Server performs many modifications to any database pages in memory/buffer cache. It will not write these modified pages to disk after every change. Rather, SQL Server Database Engine periodically issues a checkpoint on each database.
A checkpoint writes the current in-memory modified pages (known as dirty pages). After that, it transactions log information from memory to disk along with recording the information in the transaction log.
Using a better checkpoint method will enhance the server performance along with rendering a better recovery plan.
SQL Server supports four types of checkpoints. They are given below:
1. Automatic Checkpoints
2. Indirect Checkpoints
3. Manual Checkpoints
4. Internal Checkpoints
Now we will see each type of checkpoint in detail.
Automatic Checkpoints
An automatic checkpoint occurs each time the number of log records reaches the number the Database Engine estimates it can process during the time specified in the recovery interval server configuration option.
We can set the value of recovery interval using the following:
sp_configure 'recovery interval','seconds'
The recovery interval is the maximum time that a server instance should use to recover a database during a system restart.
When a database using automatic checkpoints reaches this maximum number of log records, the Database Engine issues a checkpoint on the database.
The frequency depends on the value of the recovery interval option of server configuration.
Database Engine generates automatic checkpoints for every database when we don’t define a value for target recovery time for a database. Usually, in a simple recovery model, an automatic checkpoint is queued if the log becomes 70 percent full.
Indirect Checkpoints
This checkpoint was introduced in SQL Server 2012. Indirect checkpoints provide a configurable database-level alternative to automatic checkpoints.
When a system crash, indirect checkpoints provide potentially faster, more predictable recovery time than automatic checkpoints.
We can set the TARGET_RECOVERY_TIME in the Indirect checkpoint for any database using the following ALTER DATABASE statement.
ALTER DATABASE DBNAME SET TARGET_RECOVERY_TIME =target_recovery_time {SECONDS | MINUTES}
Here the recovery interval configuration option uses the number of transactions to determine the recovery time as opposed to indirect checkpoints which make use of the number of dirty pages.
Indirect checkpoints allow us to reliably control database recovery time by factoring in the cost of random I/O during REDO. It also reduces checkpoint-related I/O spiking by continuously writing dirty pages to disk in the background.
Manual Checkpoints
The manual checkpoint is issued when we execute a T-SQL CHECKPOINT command for a database. By default, manual checkpoints run to completion and its Throttling works the same way as that of automatic checkpoints.
Internal Checkpoints
Internal Checkpoints are generated by various server components to guarantee that disk images match the current state of the log. They generate in response to the following events:
1. Adding or removing database files using ALTER DATABASE.
2. Backup of the database is taken
3. Creating a database snapshot, either explicitly or internally for DBCC CHECK.
4. Any activities leading to database shutdown.
5. An instance of SQL Server stops by stopping the SQL Server (MSSQLSERVER) service. Either action causes a checkpoint in each database in the instance of SQL Server.
6. Bringing a SQL Server failover cluster instance (FCI) offline.
[Need assistance with your SQL server? – We can help you]
Conclusion
In short, in today’s article, we saw the Checkpoint process in SQL server and the four types of checkpoints available.
0 Comments