Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

Purge Database

Purging is the process of freeing up space in the database or deleting obsolete data that is no longer required. The purge process can be based on the age of the data or the type of data. 


Functionality

In case the replication is running on the main site and the database is set up for the purge feature, then, on the export stage, Replicator generates purge requests for the satellites where the purge is enabled.

...

Replicator runs a separate replication phase called Purge database. This phase runs right after the import phase.  When the purge database is in progress, you can see in Replicator Manager what tables are purged and how many rows are deleted from each table:

...



Technical Details

Purge requests are exported at the very end of the procedure that exports data to a site. Replicator walks through the export tasks for a site once again after tasks export. It handles every table task where the new DataPurgedAfterDays or PKPurgeQuery field of the repl_ExportTasks view is set to a value other than null.

...

Code Block
ALTER VIEW [dbo].[repl_ExportTasks]

AS

SELECT …,

      PKRestrictionQuery = CASE WHEN repl_Channel.IsPartial = 1 THEN repl_Restrictions.PKRestrictionQuery ELSE NULL END

FROM …

LEFT OUTER JOIN

      dbo.repl_Restrictions ON repl_Task.TaskNr = repl_Restrictions.TaskNr AND repl_Channel.ChannelNr = repl_Restrictions.ChannelNr

WHERE …

Then, we could add the fields DataPurgedAfterDays and PKPurgeQuery to the repl_Restrictions table and references to them to the repl_ExportTasks view:

ALTER TABLE dbo.repl_Restrictions ADD DataPurgedAfterDays int;

ALTER TABLE dbo.repl_Restrictions ADD PurgeQuery varchar(8000);



ALTER VIEW [dbo].[repl_ExportTasks]

AS

SELECT …,

      DataPurgedAfterDays = CASE WHEN repl_Site.IsPurged = 1 THEN repl_Restrictions.DataPurgedAfterDays ELSE NULL END,

      PKPurgeQuery = CASE WHEN repl_Site.IsPurged = 1 THEN repl_Restrictions.PKPurgeQuery ELSE NULL END

FROM …

WHERE …



Housekeeping

Replicator enables you to benefit from the purge database functionality. For this, you have to set up the database for the purge feature. First, run APM and navigate to Setup > Adonis Replicator. Now, proceed as described below:

  1. Make sure you are on the Site Properties tab. Within the grid, in the Is Purge column, select the checkbox(es) for the site(s) for which you want to purge database.

  2. Switch to the Replication Tasks tab under Views -1 to define the number of days to apply purging and PK Purge Query:

    • In the Data Purged After Days column, enter the number days starting from today for purging to be applied.

    • In the PK Purge Query column, double-click the cell where a purge query is to be added. When the Browse button appears, click it to open the SQL Editor dialog:

      Image RemovedImage Added


      In the SQL Editor dialog, enter the SQL query or click Load to define the directory to the statement. Click Save to... to specify the save directory on your computer or Save&Close to apply the changes in the editor. 

...