sqlschool.gr logo

articles

Articles of SQLschool.gr Team

Κάθε πότε γίνεται η διαδικασία CHECKPOINT? (UPDATED)

Antonios Chatzipavlis
Thursday 05 May 2011

Όπως είναι γνωρίζουμε στον SQL Server υπάρχει μια διαδικασία  η οποία σκοπό έχει να μεταφέρει από την Buffer Cache τις αλλαγμένες σελίδες στο δίσκο, γίνεται σε όλες τις βάσεις εκτός από την tempdb (αν και αυτό δεν είναι και τόσο αλήθεια αλλά δεν θα το αναλύσουμε εδώ). Σκοπός του είναι να είναι όσο το δυνατό πιο ενημερωμένα τα data files με τις αλλαγές είναι γραμμένες στο log.

Αυτό μπορεί να γίνει είτε εκτελώντας την εντολή CHECKPOINT είτε το κάνει o SQL Server αυτόματα. Το αυτόματο μπορεί να ορίστει αν το επιθυμούμε και αυτό γίνεται ορίζοντας το Recovery Interval στο SQL Server. H default τιμή είναι μηδέν που σημαίνει ότι ο SQL Server αποφασίζει για το πότε θα την κάνει αυτή την διαδικασία.

Πρόσφατα άκουσα ότι αυτή αν δεν ορίσεις τιμή γίνεται κάθε 2 sec. Αυτό με έβαλε σε σκέψεις και αποφάσισα να το ψάξω ενδελεχώς.

Σύμφωνα με τα BOL http://msdn.microsoft.com/en-us/library/ms189573.aspx στην παράγραφο για τα Automatic Checkpoints αναφέρει

The SQL Server Database Engine generates automatic checkpoints. The interval between automatic checkpoints is based on the amount of log space used and the time elapsed since the last checkpoint. The time interval between automatic checkpoints can be highly variable and long, if few modifications are made in the database. Automatic checkpoints can also occur frequently if lots of data is modified.

Αυτό όμως δεν μου έφτασε και άρχισα να κοιτάζω περισσότερα. Έφτασα σε ένα σημείο να ρωτήσω και ανθρώπους που τον έχουν φτιάξει (δεν αναφέρω τα ονόματα τους για μην θεωρηθεί ότι πουλάω μούρη ότι μιλάω μαζί τους). Τελικά οι ερωτήσεις μου και οι αναζητήσεις μου είχαν αποτέλεσμα και ανακάλυψα ότι μπορείς να χρησιμοποιήσεις τα trace flags 3502 και 3605  τα οποία γράφουν μέσα στο error log το κάθε πότε γίνεται checkpoint.

Επίσης είναι αρκετά εύκολο να το δεις κάνοντας monitor τον Buffer Manager\Checkpoint Pages per Sec perfmon counter.

Με ποιά όμως λογική γίνεται trigger η αυτόματη διαδικασία? Η απάντηση δια στόματος του Paul Randal είναι η παρακάτω

A checkpoint is triggered automatically under a variety of conditions. The most common condition is that enough transaction log has been generated that SQL Server estimates that if the server was to crash, it would take about one minute for crash recovery to complete. This is calculated based on the number of log records that have been generated since the last checkpoint and is known as the recovery interval. The next most common condition that triggers a checkpoint is when the log becomes 70% full.

 

 

@antonch

Antonios Chatzipavlis

Antonios Chatzipavlis

Antonios Chatzipavlis is a highly experienced Data Solutions Consultant and Trainer. He has been working in the IT industry since 1988, holding various roles such as senior developer, IT Manager, Data & AI Solutions Architect and Consultant.

Since 1995, Antonios has focused on modern technologies and software development tools, primarily by Microsoft. He has specialized in Data & AI since 2000, with expertise in Microsoft Data Platform (SQL Server, Azure SQL Databases, Azure Synapse Analytics, Microsoft Fabric, Power BI, AI) and Databricks.

Antonios is also a Microsoft Certified Trainer (MCT) for over 25 years, has been recognized as a Microsoft Most Valuable Professional (MVP) in Data Platform since 2010 and he is in the Data Expert 40 Powerlist 2024 by Boussias. He is the co-founder and visionary behind XLYTiCA, a company dedicated to Data & AI solutions.

Episode

Task Flows in Microsoft Fabric

image

More Episodes...

Tip

Get Certified: Become a Fabric Data Engineer

More Tips...

Become a member

If you want to receive updates from us become a member to our community.

Connect

Explore

Learn


sqlschool.gr © 2010-2025 All rights reserved

This site uses cookies for operational and analytics purposes only. By continuing to browse this site, you agree to their use.