A new Flexera Community experience is coming on November 18th, click here for more information.
Apr 13, 2019 06:54 AM
Apr 14, 2019 07:41 PM
Here is a recipe that may help here.
Over time, the FlexNet Manager Suite compliance database can grow very large. Inspection of the relative sizes of tables in the database will often indicate that the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables are the largest tables by an order of magnitude. These tables hold a history of changes made on many different types of records held in the database, and grow in size indefinitely under normal operation of the system.
A SQL script can be used to delete old and unwanted records from the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables (both of which are accessed via the dbo.ComplianceHistory view) in the FlexNet Manager Suite compliance database.
An example of such a script is:
-- Drop existing #ToDelete table if it exists so this script can be re-run easily IF OBJECT_ID('tempdb..#ToDelete') IS NOT NULL DROP TABLE #ToDelete -- Identify history records to be deleted SELECT ch.ComplianceHistoryID INTO #ToDelete FROM dbo.ComplianceHistory WHERE <Insert condition here to identify which records you want to delete> CREATE CLUSTERED INDEX IX_#ToDelete ON #ToDelete(ComplianceHistoryID) DECLARE @DeletedCount INT DECLARE @BatchCount INT SET @BatchCount = 1 WHILE 1=1 BEGIN -- Delete in batches of 10,000 records to avoid locking data for too long DELETE TOP(10000) ch FROM dbo.ComplianceHistory ch JOIN #ToDelete d ON d.ComplianceHistoryID = ch.ComplianceHistoryID SET @DeletedCount = @@ROWCOUNT PRINT CONVERT(NVARCHAR, GETDATE()) + ': Deletion batch ' + CONVERT(NVARCHAR, @BatchCount) + ': deleted ' + CONVERT(NVARCHAR, @DeletedCount) + ' rows' IF @DeletedCount = 0 BREAK SET @BatchCount = @BatchCount + 1 WAITFOR DELAY '00:00:01' -- Give the database a chance to breathe END
A script like this is likely to run for many hours or even days if a large amount of data is to be deleted.
If a large number of records get cleaned up in this way at any point, consider shrinking database data file(s) to reclaim disk space.
Configure a script such as this to run on a regular basis (say, weekly over the weekend, or monthly) using a SQL Server Agent job or other scheduling mechanism.
Possible extensions to this script might be:
Apr 22, 2019 06:17 AM
Apr 14, 2019 07:41 PM
Here is a recipe that may help here.
Over time, the FlexNet Manager Suite compliance database can grow very large. Inspection of the relative sizes of tables in the database will often indicate that the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables are the largest tables by an order of magnitude. These tables hold a history of changes made on many different types of records held in the database, and grow in size indefinitely under normal operation of the system.
A SQL script can be used to delete old and unwanted records from the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables (both of which are accessed via the dbo.ComplianceHistory view) in the FlexNet Manager Suite compliance database.
An example of such a script is:
-- Drop existing #ToDelete table if it exists so this script can be re-run easily IF OBJECT_ID('tempdb..#ToDelete') IS NOT NULL DROP TABLE #ToDelete -- Identify history records to be deleted SELECT ch.ComplianceHistoryID INTO #ToDelete FROM dbo.ComplianceHistory WHERE <Insert condition here to identify which records you want to delete> CREATE CLUSTERED INDEX IX_#ToDelete ON #ToDelete(ComplianceHistoryID) DECLARE @DeletedCount INT DECLARE @BatchCount INT SET @BatchCount = 1 WHILE 1=1 BEGIN -- Delete in batches of 10,000 records to avoid locking data for too long DELETE TOP(10000) ch FROM dbo.ComplianceHistory ch JOIN #ToDelete d ON d.ComplianceHistoryID = ch.ComplianceHistoryID SET @DeletedCount = @@ROWCOUNT PRINT CONVERT(NVARCHAR, GETDATE()) + ': Deletion batch ' + CONVERT(NVARCHAR, @BatchCount) + ': deleted ' + CONVERT(NVARCHAR, @DeletedCount) + ' rows' IF @DeletedCount = 0 BREAK SET @BatchCount = @BatchCount + 1 WAITFOR DELAY '00:00:01' -- Give the database a chance to breathe END
A script like this is likely to run for many hours or even days if a large amount of data is to be deleted.
If a large number of records get cleaned up in this way at any point, consider shrinking database data file(s) to reclaim disk space.
Configure a script such as this to run on a regular basis (say, weekly over the weekend, or monthly) using a SQL Server Agent job or other scheduling mechanism.
Possible extensions to this script might be:
Apr 22, 2019 06:17 AM
Does deleting from ComplianceHistory also delete from ComplianceHistory_MT and ComplianceHistoryLimited_MT? We have much older data (3 years older) in ComplianceHistoryLimited_MT than ComplianceHistory_MT so I was wondering if there are database triggers on the ComplianceHistory View to clean both tables or should we run two scripts to clean the tables separately?
Thank you
Aug 20, 2021 07:13 AM
The short answer is yes: deleting from ComplianceHistory will delete from ComplianceHistory_MT and ComplianceHistoryLimited_MT.
ComplianceHistory itself is a view. In some compliance databases (depending on which versions of FlexNet Manager Suite have been installed in the past), you will find an "INSTEAD OF DELETE" trigger defined on this view which will delete records from the dbo.ComplianceHistory_MT and dbo.ComplianceHistoryLimited_MT tables which underlie the view.
Aug 20, 2021 07:24 AM
Hello Oliver,
Deleting compliance computer records could take days and eventually cause locks if other activities happen (inventory import).
One approach is to use the script above and schedule a SQL server agent that will run every day from 10:00 AM to 5:00 PM (typically out of the inventory import time). Will select the top 5 million records... deleting by batches of 50K, with a commit every 50K records, to avoid a growth in log files. This is the first attached document.
Another approach that is way more efficient (extremely fast) is attached in the second script: this approach makes sense if the cleanup must be massive and impact potentially several billions of records. The approach is the following:
The interest of the scriptare the following
and you get for free an FNMS Inventory Computer cleanup script 🙂
Aug 26, 2021 01:49 AM - edited Aug 26, 2021 02:09 AM
User | Count |
---|---|
8 | |
7 | |
3 | |
3 |