Tuesday, April 15, 2014

difference between Checkpoint and Lazy Writer

 difference between Checkpoint and Lazy Writer
RowCheckpointLazy writer
1Checkpoint is used by sql engine to keep database recovery time in checkLazy writer is used by SQL engine only to make sure there is enough memory left in sql buffer pool to accommodate new pages
2Check point always mark entry in T-log before it executes either sql engine or manuallyLazy writer doesn’t mark any entry in T-log
3To check occurrence of checkpoint , we can use below query
select * from ::fn_dblog(null,null)
WHERE [Operation] like ‘%CKPT’
To check occurrence of lazy writer we can use performance monitor
SQL Server Buffer Manager Lazy writes/sec
4Checkpoint only check if page is dirty or notLazy writer clears any page from memory when it satisfies all of 3 conditions.
1.      Memory is required by any object and available memory is full
2.      Cost factor of page is zero
3.      Page is not currently reference by any connection
5Checkpoint is affected by two parameters
1.      Checkpoint duration: is how long the checkpoint can run for.
2.      Recovery interval: affects how often it runs.
Lazy writer is affected by
1.      Memory pressure
2.      Reference counter of page in memory
6Check point should not be very low , it can cause increasing recovery time of databaseNo. of times lazy writer is executing per second should always be low else it will show memory pressure
7Checkpoint will run as per defined frequencyNo memory pressure, no lazy writer
8Checkpoint tries to write as many pages as fast as possibleLazy writer tries to write as few as necessary
9checkpoint process does not put the buffer page back on the free listLazy writer scans the buffer cache and reclaim unused pages and put it n free list
10We can find last run entry of checkpoint in Boot pageLazy writer doesn’t update boot page
11Checkpoint can be executed by user manually or by SQL engineLazy writer cant be controlled by user
12It keeps no. of dirty pages in memory to minimumIt helps to reduce paging
13Auto frequency can be controlled using recovery interval in sp_configureWorks only @ memory pressure , It uses clock algorithm for cleaning buffer cache
14It will be automatically executed before every sql statement which requires consistent view of database to perform task like (Alter, backup, checkdb, snapshot …..)It kicks pages out of memory when reference counter of page reaches to zero
15Command : CheckpointNo command available
16It comes in picture to find min lsn whenever t-log truncatesNo entry in T-log
17Checkpoint is affected by Database recovery modelLazy writer doesn’t get impacted with recovery model of database
18To get checkpoint entry in error log
DBCC TRACEON(3502, -1)
Not Applied
19Members of the SYSADMIN, DB_OWNER and DB_BACKUPOPERATOR can execute checkpoint mauallyNot Applied
 
 
 

No comments:

Post a Comment