Download presentation
Presentation is loading. Please wait.
Published byMarion Dean Modified over 9 years ago
1
Transaction Log Internals Dharmendra Keshari President - KDSSG
2
Who Am I…. Reachable at: https://sg.linkedin.com/pub/dharmendra-keshari/98/433/a70 https://www.facebook.com/dharmendra.keshari.9 Dharmendra.Keshari@kdssg.com Dharmendra.keshari@gmail.com PH - +65-83895125 With 8+ years of working experience, Dharmendra Keshari has strong and in-depth Experience in Database Management. Currently, work as Senior Database Administrator in Working one of the best Semi-Government company In Singapore. His experience in executing critical projects on large scale, combined with providing day-to-day solutions, gives him unique ability to solve several complex Database problems. He is an avid and regular mentor on social media, helping several techies in solving problems related to Database management. Certified on Administering; – Microsoft SQL Server® 2008, Implementation and Maintenance – Administering Microsoft SQL Server 2012 Database Major Key skills set areas; Performance and Tuning of SQL Server Database Virtualization and Consolidation HA Solution on Instance and Database Level
3
Transaction Log File Transaction file is the place where we store transaction log records. Basic Terminology of Transaction Log….. Transaction Any change to a database is done within confine, the confine is known as a transaction & every transaction will have TransactionID. There are some transactions which are non-transactional. Log Record A Log records is a description of a single change or small change to a database. A transaction may be consisting of single or multiple log records. Commit It means finalizing a transaction. In other words, Commit makes transaction durable meaning we can’t roll back any transaction if they have been committed. Roll Back Roll back transaction means aborting a transaction. It means it is going to remove all the changes that have been marked to a database and it will bring the database in the old state where it was.
4
Checkpoint Checkpoint is a mechanism that write out dirty data-file pages to disk after an interval. It helps to reduce disk I/O and recovery interval time. Basic Terminology of Transaction Log (2) Crash If a SQL Server instance shuts down unexpectedly and databases couldn’t get chance to close all the active transactions. This is known as crashing of SQL Server. Recovery When a database needs to be made transitionally consistent, after a fraction of second crashes occurred then recovery has to run. If the recovery is running because of crash that is called crash recovery.
5
Transaction Log Architecture
8
VLF Sequence Number Log Block Sequence Number Log Record Sequence Number
9
DEMO : Basic Terminology & Log Architecture
10
VLFs Algorithm & Management
11
<= 2012 <=1MB, it is going to create 2 new VLF (Each VLF’s ½ of the growth size) >1MB to <=64MB, it’s going to create 4 new VLFs (Each VLF’s ¼ of the growth size) >64MB to <=1GB, it’s going to create 8 new VLFs (Each VLF’s 1/8 of the growth size) >1 GB, it is going to created 16 new VLF (Each VLF’s 1/16 of the growth size) For SQL Server 2014 If the growth size is less than 1/8 the size of the current log size? YES : Create 1 new VLF equal to the growth size NO: use the above formula
12
Recovery Unit ID Added in SQL server 2012 but as of now it is unused. FileId Transaction log file ID with in the database. FileSize It is the size of the VLF in bytes not of the transaction log file. StartOffset The offset of the VLF within the entire transaction log files; starts with 8192 bytes that’s because file header and it does not store log records. Status Whether the VLF is active or not (0 = inactive, 2 = active, 1 is not used) FSeqNo VLF sequence number for very first VLF in a new database is whatever the model database highest VLF sequence number is + 1. Parity Every time a VLF is reused, the parity value is switched. It has three different values. CreateLSN When the log file (or DB was first created) was initially created, LSN number is 0. All other VLF that added after the initial creation of the log file will have non zero CreateLSN
13
What are Log Records? What are “Log Record” Contents? Log Records in Transactions? What is Log Space Reservation? What are the “Log Record” Types? What is COMPENSATION Log Records ? Log Records Operations
14
DEMO : VLF CREATION|DBCC LOGINFO|LOG RECORD
15
Slow performance when you recover a database if there are many VLFs inside the transaction log in SQL Server 2005, in SQL Server 2008 or in SQL Server 2008 R2 https://support.microsoft.com/en-us/kb/2455009 Certain database operations take a very long duration to complete or encounter errors when the transaction log has numerous virtual log files https://support.microsoft.com/en-us/kb/2028436 Transaction Log VLFs – too many or too few? http://www.sqlskills.com/blogs/kimberly/transaction-log-vlfs-too-many-or-too-few/ Bug: log file growth broken for multiples of 4GB http://www.sqlskills.com/blogs/paul/bug-log-file-growth-broken-for-multiples-of-4gb/ Can log files growth affect DML? Post-CU Update http://blogs.msdn.com/b/blogdoezequiel/archive/2011/04/26/can-log-files-growth- affect-dml-post-cu6-update.aspx#.VbDOpukViM9 Can log files growth affect DML? http://blogs.msdn.com/b/blogdoezequiel/archive/2010/10/26/can-log-files-growth- affect-dml.aspx#.VbDIXukViM9 VLF Fragmentation’s Issue
16
Question and Answer !!!!
17
Thank you for attending Tech Unite
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.