1

How do we find out a LSN given a timestamp given that CDC is disabled ? I know that in case when CDC is enabled it can be done via fn_cdc_map_time_to_lsn stored procedure but is there a way to get to the same info when CDC is not enabled.

Ravi Jain
  • 86
  • 1
  • 4

1 Answers1

1

I don't think there's a supported way to do that. You could use the undocumented fn_dblog, eg

select l.[Current LSN], coalesce([Begin Time],[End Time]) lsn_time
from  fn_dblog(null,null) l
where [Begin Time] is not null or [End Time] is not null 
David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • Thanks David. Actually we are looking to understand how can we identify values to put in the input of fn_dblog so this won't help us. The usecase being that we want to partition reading logs via fn_dblog on the basis of time and parallelize logs reading. – Ravi Jain Oct 12 '22 at 03:48
  • 1
    Other such solutions turn on CDC for the database, but not for any tables. – David Browne - Microsoft Oct 12 '22 at 07:55
  • Thanks Again David. When we enabled CDC with tables, we found that lsn to time mapping is lagging when we have write heavy load on DB. I need to check that does this lsn to time mapping will have any lag when CDC is enabled. – Ravi Jain Oct 13 '22 at 03:34
  • I think it's maintained asynchronously by the log reader, just like CDC change data, so there's the potential for lag under heavy load. – David Browne - Microsoft Oct 13 '22 at 14:35