I am learning to use CDC in SQL server 2008, I have read that LSN is always incremented and is based upon timestamp, so why LSN is required, if it is calculated from timestamp which can be used as increamental sequence id for changes made. I am sure that there will be some other purpose as well of lsn.
1 Answer
A date/time value is generally not considered to be unique enough. No matter how fine you define it, it is possible to have 2 actions occurring for the same datetime value.
Prior to SQL Server 2008, the most accurate value was a rounded 3.33 milliseconds with datetime
which is an eternity really. datetime2
resolves to 100 nanoseconds which isn't accurate enough either.
From another view, time is is a real number. No matter how accurately you store a time, there is always some rounding to your level of resolution (In this case, 3.33 ms or 100 ns)
Using LSN (which is numeric (25,0)
) gives a strictly monotonically increasing unambiguous whole number value. It is a natural number
-
2Most RDBMSes do the same - Oracle uses a system change number (SCN), for example.– PhilᵀᴹCommented Mar 25, 2013 at 12:14