Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2017 March SQL Server: What is a Log Sequence Number (LSN)?

SQL Server: What is a Log Sequence Number (LSN)?

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

I know this is not a new topic, but many SQL Database Administrator doesn’t know about the importance of LSNs, so I am sharing one of the important discussion about the SQL Server LSNs which are very necessary for Database backup and restore activities.

What is LSN?

Every record in the SQL Server transaction log is uniquely identified by a Log Sequence Number (LSN).
The LSNs are sequential, and in the particular ordered, new LSN is always higher than the old LSN.
The LSN is a type of Numeric(25,0), so we can compare different LSNs using equality operators.

The importance of LSN:

Generally, when we are restoring database, we are restoring in this sequence: Full Database backup -> Differential backup -> Transaction Log backup.

We cannot restore the Differential backup before the Full database backup because LSN is sequentially starting from the full database backup.

Before restoring of the Differential backup and Transaction Log backup, it checks FirstLSN, LastLSN, CheckpointLSN, DatabaseBackupLSN columns.

If LastLSN of the first file and FirstLSN of the second file doesn’t match, it fails to restore Differential backup and Transaction log backup.

The sequence of LSNs is critical to restoring your database because all different database backup files virtually connected with each other.

The first full database backup will always have a DatabaseBackupLSN of zero and FirstLSN is same as CheckpointLSN.

The Full database backup CheckpointLSN is a
DatabaseBackupLSN for all differential databases.

The LastLSN of Differential backup will be between FirstLSN and LastLSN of the Transaction Log backup.

Mar 30, 2017Anvesh Patel
SQL Server 2016: STRING_SPLIT to Split a String by Different DelimitersSQL Server: Find Log Sequence Number (LSN) from Database Backup Files
Comments: 2
  1. Santhosh Reddy
    August 18, 2018 at 4:19 pm

    Thank you for sharing valuable information. Now I understand the importance of LSN in restoring the different database back files.

    ReplyCancel
  2. rardCal
    December 2, 2019 at 8:04 pm

    i am from Italy hello. Can you help me translate? /rardor

    ReplyCancel

Leave a Reply to rardCal Cancel reply

CAPTCHA
Refresh

*

Anvesh Patel
Anvesh Patel

Database Engineer

March 30, 2017 2 Comments SQL ServerAnvesh Patel, backup, CheckpointLSN, database, database research and development, dbrnd, FirstLSN, LastLSN, Log Sequence Number, LSN, SQL Query, SQL Server, SQL Server Administrator, SQL Server Monitoring, SQL Server Performance Tunning, SQL Server Tips and Tricks, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....