Home
%3CLINGO-SUB%20id%3D%22lingo-sub-388209%22%20slang%3D%22en-US%22%3ETransactions%2C%20Validation%20Issue%20and%20Staging%20table%20cleanup%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-388209%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Jun%2002%2C%202015%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CB%3E%20Transactions%2C%20Validation%20Issue%20and%20Staging%20table%20cleanup%3A%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EMaster%20Data%20Services%20previous%20versions%20didn%E2%80%99t%20have%20a%20supported%20way%20to%20clean%20the%20transaction%20logs%2C%20validation%20issues%20history%20and%20Staging%20tables.%20For%20a%20MDS%20system%20with%20lot%20of%20data%20changes%20and%20ETL%20processes%20these%20tables%20can%20grow%20exponentially%20and%20lead%20to%20performance%20degradation%20and%20storage%20space%20issues.%3C%2FP%3E%0A%20%20%3CP%3EIn%20the%20next%20release%20of%20Master%20Data%20Service%20(which%20will%20be%20part%20of%20next%20SQL%20Server%20release%20SQL%20vNext)%20we%20will%20provide%20option%20to%20clean%20these%20tables%20on%20a%20pre-determined%20intervals%20or%20schedule.%20Based%20on%20the%20user%20setting%20the%20data%20in%20these%20tables%20will%20be%20truncated.%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20What%20is%20cleaned%3F%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EAll%20the%20transaction%20history%20older%20than%20specified%20number%20of%20days%2C%20all%20the%20validation%20issues%20history%20older%20than%20specified%20number%20of%20days%20and%20all%20the%20staging%20batches%20which%20ran%20before%20specified%20number%20of%20days.%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20How%3A%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EThere%20will%20be%20settings%20where%20user%20can%20specify%20for%20how%20many%20days%20he%20wants%20to%20retain%20the%20logs%20and%20data%20in%20these%20tables.%20He%20can%20do%20this%20in%20two%20places.%20One%20using%20a%20System%20Setting%20(LogRetentionDays)%20which%20will%20apply%20to%20all%20the%20models%20in%20the%20system.%20Second%20ways%20is%20to%20set%20the%20property%20at%20Model%20level%20which%20will%20override%20the%20system%20level%20setting.%3C%2FP%3E%0A%20%20%3CP%3E%3CI%3E%20System%20Setting%3A%20%3C%2FI%3E%3C%2FP%3E%0A%20%20%3CP%3EBy%20default%20the%20system%20setting%20will%20be%20-1%20which%20means%20do%20not%20truncate%2Fclean%20any%20tables.%20If%20the%20value%20is%200%20then%20the%20tables%20will%20retain%20only%20today%E2%80%99s%20data%20and%20all%20the%20previous%20days%20data%20logs%20will%20be%20truncated.%20For%20n%20%26gt%3B%200%20the%20logs%20will%20be%20retained%20for%20n%20number%20of%20days.%3C%2FP%3E%0A%20%20%3CP%3ETo%20set%20this%20value%20use%20the%20MDS%20Configuration%20Manger%20tool%20and%20change%20the%20setting%20shown%20below.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99868i89A8BF7EC03E6EB4%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CI%3EModel%20level%20Setting%20%3C%2FI%3E%20%3A%3C%2FP%3E%0A%20%20%3CP%3EBy%20default%20the%20model%20setting%20is%20NULL%20which%20means%20the%20value%20will%20be%20inherited%20from%20the%20System%20Setting%20%E2%80%9CLog%20Retention%20in%20Days%E2%80%9D.%20If%20you%20want%20to%20override%20system%20setting%20and%20NOT%20clean%20any%20logs%20then%20set%20as%20-1.%20If%20you%20do%20not%20want%20to%20retain%20any%20transaction%20logs%20and%20validation%20history%20and%20already%20processed%20staging%20data%20then%20set%20as%200.%20For%20n%20%26gt%3B%200%20the%20logs%20will%20be%20retained%20for%20n%20number%20of%20days.%20Acceptable%20values%3A%20-1%20to%205000.%3C%2FP%3E%0A%20%20%3CP%3ETo%20Set%20or%20Update%20the%20Model%20property%20in%20the%20MDS%20Web%20UI%20go%20to%20System%20Administration%20-%26gt%3B%20Manage%20-%26gt%3B%20Model%20and%20change%20the%20property%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F99869i93E92E53CB6B9458%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CI%3EScheduler%20%3C%2FI%3E%20%3CI%3E%20%3A%3C%2FI%3E%3C%2FP%3E%0A%20%20%3CP%3EWhen%20you%20create%20the%20database%20from%20Configuration%20Manager%2C%20by%20default%20it%20schedules%20a%20SQL%20Agent%20Job%2C%20%E2%80%9C%20%3CI%3E%20MDS_%3CDB%20name%3D%22%22%3E_Log_Maintenance%20%3C%2FDB%3E%3C%2FI%3E%20%E2%80%9D%20which%20triggers%20every%20day%20at%202AM%20and%20scans%20all%20the%20models%20and%20cleans%20the%20table%20as%20per%20the%20settings%20above.%3C%2FP%3E%0A%20%20%3CP%3EIf%20you%20want%20to%20change%20the%20frequency%20of%20this%20job%20then%20use%20the%20SQL%20Agent%20-%26gt%3B%20Job%20(MDS%20%3CI%3E%20_%3CDB%20name%3D%22%22%3E_Log_Maintenance%20%3C%2FDB%3E%3C%2FI%3E%20)%20and%20update%20the%20schedule.%20You%20can%20use%20SQL%20Server%20Management%20Studio%20to%20make%20any%20changes%20to%20this%20scheduled%20job.%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20%3CI%3E%20How%20to%20manually%20cleanup%20the%20tables%20without%20setting%20a%20recurring%20cleanup%20as%20above%20%3C%2FI%3E%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EYou%20can%20call%20the%20Stored%20Procedures%20manually%20which%20will%20clean%20up%20the%20tables.%20To%20clean%20Transaction%20tables%20use%20mdm.udpTransactionsCleanup%2C%20to%20clean%20Validation%20History%20use%20mdm.udpValidationsCleanup%20and%20to%20clean%20staging%20table%20use%20mdm.udpEntityStagingBatchTableCleanup.%3C%2FP%3E%0A%20%20%3CP%3E%3CI%3E%20Sample%3A%20%3C%2FI%3E%3C%2FP%3E%0A%20%20%3CP%3EDECLARE%20%40CleanupOlderThanDate%20date%20%3D%20'2014-11-11'%2C%3C%2FP%3E%0A%20%20%3CP%3E%40ModelID%20INT%20%3D%207%3C%2FP%3E%0A%20%20%3CP%3E--Cleanup%20Transaction%20Logs%3C%2FP%3E%0A%20%20%3CP%3EEXEC%20mdm.udpTransactionsCleanup%20%40ModelID%2C%20%40CleanupOlderThanDate%3B%3C%2FP%3E%0A%20%20%3CP%3E--Cleanup%20Validation%20History%3C%2FP%3E%0A%20%20%3CP%3EEXEC%20mdm.udpValidationsCleanup%20%40ModelID%2C%20%40CleanupOlderThanDate%3B%3C%2FP%3E%0A%20%20%3CP%3E--Claenup%20EBS%20tables%3C%2FP%3E%0A%20%20%3CP%3EEXEC%20mdm.udpEntityStagingBatchTableCleanup%20%40ModelID%2C%20%40CleanupOlderThanDate%3B%3C%2FP%3E%0A%20%20%3CP%3E%3CSTRONG%3E%20More%20related%20information%20can%20be%20found%20at%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%20%20%3CBLOCKQUOTE%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fff714019(v%3Dsql.130).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Transactions%20(Master%20Data%20Services)%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3C%2FBLOCKQUOTE%3E%0A%20%20%3CBLOCKQUOTE%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fff487007(v%3Dsql.130).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20Create%20a%20Model%20(Master%20Data%20Services)%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fff487028(v%3Dsql.130).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20System%20Settings%20(Master%20Data%20Services)%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3C%2FBLOCKQUOTE%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-388209%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Jun%2002%2C%202015%20Transactions%2C%20Validation%20Issue%20and%20Staging%20table%20cleanup%3A%20Master%20Data%20Services%20previous%20versions%20didn%E2%80%99t%20have%20a%20supported%20way%20to%20clean%20the%20transaction%20logs%2C%20validation%20issues%20history%20and%20Staging%20tables.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-388209%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Emaster%20data%20services%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emds%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQL%20Server%202016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esql2016%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Not applicable
First published on MSDN on Jun 02, 2015

Transactions, Validation Issue and Staging table cleanup:

Master Data Services previous versions didn’t have a supported way to clean the transaction logs, validation issues history and Staging tables. For a MDS system with lot of data changes and ETL processes these tables can grow exponentially and lead to performance degradation and storage space issues.

In the next release of Master Data Service (which will be part of next SQL Server release SQL vNext) we will provide option to clean these tables on a pre-determined intervals or schedule. Based on the user setting the data in these tables will be truncated.

What is cleaned?

All the transaction history older than specified number of days, all the validation issues history older than specified number of days and all the staging batches which ran before specified number of days.

How:

There will be settings where user can specify for how many days he wants to retain the logs and data in these tables. He can do this in two places. One using a System Setting (LogRetentionDays) which will apply to all the models in the system. Second ways is to set the property at Model level which will override the system level setting.

System Setting:

By default the system setting will be -1 which means do not truncate/clean any tables. If the value is 0 then the tables will retain only today’s data and all the previous days data logs will be truncated. For n > 0 the logs will be retained for n number of days.

To set this value use the MDS Configuration Manger tool and change the setting shown below.

Model level Setting :

By default the model setting is NULL which means the value will be inherited from the System Setting “Log Retention in Days”. If you want to override system setting and NOT clean any logs then set as -1. If you do not want to retain any transaction logs and validation history and already processed staging data then set as 0. For n > 0 the logs will be retained for n number of days. Acceptable values: -1 to 5000.

To Set or Update the Model property in the MDS Web UI go to System Administration -> Manage -> Model and change the property shown below

Scheduler :

When you create the database from Configuration Manager, by default it schedules a SQL Agent Job, “ MDS_<DB Name>_Log_Maintenance ” which triggers every day at 2AM and scans all the models and cleans the table as per the settings above.

If you want to change the frequency of this job then use the SQL Agent -> Job (MDS _<DB Name>_Log_Maintenance ) and update the schedule. You can use SQL Server Management Studio to make any changes to this scheduled job.

How to manually cleanup the tables without setting a recurring cleanup as above

You can call the Stored Procedures manually which will clean up the tables. To clean Transaction tables use mdm.udpTransactionsCleanup, to clean Validation History use mdm.udpValidationsCleanup and to clean staging table use mdm.udpEntityStagingBatchTableCleanup.

Sample:

DECLARE @CleanupOlderThanDate date = '2014-11-11',

@ModelID INT = 7

--Cleanup Transaction Logs

EXEC mdm.udpTransactionsCleanup @ModelID, @CleanupOlderThanDate;

--Cleanup Validation History

EXEC mdm.udpValidationsCleanup @ModelID, @CleanupOlderThanDate;

--Claenup EBS tables

EXEC mdm.udpEntityStagingBatchTableCleanup @ModelID, @CleanupOlderThanDate;

More related information can be found at:

Transactions (Master Data Services)

Create a Model (Master Data Services)

System Settings (Master Data Services)