Aged Data Not Removed in Azure SQL Temporal History Table

Cuiwei (Syncia) Lu 0 Reputation points
2023-08-02T22:59:44.0266667+00:00

I have created a testing temporal table with retention policy set to 1 days following the link

https://learn.microsoft.com/en-us/azure/azure-sql/database/temporal-tables-retention-policy?view=azuresql-mi

All requirement are met based on the documentation. However, the aged record is not removed automatically from history table.

running query select ValidTo from [dbo].[TestHistory] where ValidTo < DATEADD (day, -1, SYSUTCDATETIME())

return me the test historical record with ValidTo=2023-04-14T00:04:14.0000000 .

So the aged record does not get removed.

1.What is the process/job in azure SQL that cleans up temporal history table based on retnetion policy defined.

  1. and what's the schedule time of the process run?

3.How can we see the run status of the job/process?

Thank you for your help.

Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. ShaktiSingh-MSFT 16,276 Reputation points
    2023-08-03T04:35:15.14+00:00

    Hi
    Cuiwei (Syncia) Lu
    •,

    Welcome to Microsoft Q&A forum.

    As I understand, Aged Data Not Removed in Azure SQL Temporal History Table.

    Could you please refer to the similar Q&A post if this helps https://learn.microsoft.com/en-us/answers/questions/68851/aged-data-not-removed-in-sql-server-temporal-histo

    Let us know if you have a different ask. Thanks

    0 comments No comments

  2. ShaktiSingh-MSFT 16,276 Reputation points
    2023-08-09T04:07:06.7766667+00:00

    Hi
    Cuiwei (Syncia) Lu
    •,

    Thanks for confirming.

    After you define retention policy, Azure SQL Database and Azure SQL Managed Instance starts checking regularly if there are historical rows that are eligible for automatic data cleanup. Identification of matching rows and their removal from the history table occur transparently, in the background task that is scheduled and run by the system. Age condition for the history table rows is checked based on the column representing end of SYSTEM_TIME period. If retention period, for example, is set to six months, table rows eligible for cleanup satisfy the following condition:

    ValidTo < DATEADD (MONTH, -6, SYSUTCDATETIME())

    Read here for more details: https://learn.microsoft.com/en-us/azure/azure-sql/database/temporal-tables-retention-policy?view=azuresql-mi

    Hope this helps. Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.