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 is a Data Solutions Consultant and Trainer. He has been working in IT since 1988. In his career, he has worked as senior developer, IT Manager, Solutions Architect and IT Consultant. Since 1995 he has been devoted on new technologies and software development tools, mainly by Microsoft, either by training company staff and colleagues or assisting them in design, development and implementation as a consultant or chief developer. He has focused in Databases and Data Science since 1995. He specialized in Microsoft SQL Server since version 6.0 in areas like SQL Server Internals, Database Design and Development, Business Intelligence and in 2010 he has started working with Azure Data Platform, NoSQL databases, Big Data Technologies and Machine Learning. He is an active member of many IT communities in Greece, answering colleagues' questions and writing articles in his web site. He is the owner of SQLschool.gr which is a community portal with a lot of information about Microsoft SQL Server. He has been a Microsoft Certified Trainer (MCT) since 2000. Microsoft honored him as MVP on Data Platform due to his activities in SQL Server since 2010. He holds a large number of Microsoft Certifications and Microsoft SQL Server Certifications since version 6.5.

Episode

Introduction to Microsoft Fabric

image

More Episodes...

Tip

Refresh Intellisence in SSMS

Για να κάνουμε refresh το intellisence μέσα στο SSMS αρκεί να πατήσουμε Ctrl+Shift+R

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-2023 All rights reserved

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