Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Reorganize Database Indexes

The automatic clean-up functionality of Connect removes a significant number of records resulting in fragmentation of the corresponding database indexes. To address this issue, the following SQL script should be scheduled for daily database maintenance:

DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'PerformanceRecords')

To reorganize all Connect application specific indexes, use th following SQL script:

DBCC INDEXDEFRAG(0, 'ConnectObjects')
DBCC INDEXDEFRAG(0, 'ConnectObjectsHistory')
DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'PerformanceRecords')
DBCC INDEXDEFRAG(0, 'ScenarioRegistrations')
DBCC INDEXDEFRAG(0, 'SecureStoreItems')

Delete obsolete data

If there is a need to delete all Contexts and Performance Records created before a specific date, the following script can be employed. Be aware that fragmented indexes may cause poor performance during deletion. If required, defragment these indexes prior to deleting data. Ensure to adjust the date in the first line of the script as needed:

DECLARE @DeleteBefore DATETIME = CAST('2000-12-31T00:00:00' AS DATETIME);

DELETE FROM Contexts WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM ContextIndices WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM ContextLogs WHERE FlowContextId IN (SELECT Id FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore);
DELETE FROM Contexts WHERE FlowContextId IS NULL AND CreateTime < @DeleteBefore;
DELETE FROM PerformanceRecords WHERE [Time] < @DeleteBefore;

DBCC INDEXDEFRAG(0, 'Contexts')
DBCC INDEXDEFRAG(0, 'ContextIndices')
DBCC INDEXDEFRAG(0, 'ContextLogs')
DBCC INDEXDEFRAG(0, 'PerformanceRecords')

Schedule index reorganization when using Azure SQL Database

Step 1: Setup Azure Automation account

If you do not have an existing Azure Automation account you need to setup a new one. Proceed as follows:

  1. Navigate to the Azure portal.

  2. Click on “Create a resource” and search for “Automation”.

  3. Select “Automation” and click “Create”.

  4. Enter a unique name for your Automation account.

  5. Select an existing resource group or create a new one.

  6. Choose the appropriate Azure region.

  7. Click “Review + create” and then “Create”.

Step 2: Add credentials for database access

  1. In the Azure portal, navigate to your newly created Automation account.

  2. Under Shared Resources, select Credentials.

  3. Click “Add credentials”.

  4. Enter a Name (e.g., “ConnectDatabaseCredentials”).

  5. Enter the database administrator user name and passwort and re-enter the password to confirm it.

  6. Click “Create”.

Step 3: Create a Runbook

  1. In the Azure portal, navigate to your newly created Automation account.

  2. Under Process Automation, select Runbooks.

  3. Click “Browse catalog” and search for “fragmentation”.

  4. Select the template “Indexes tables in an Azure database if they have a high fragmentation“.

  5. Click “Select”.

  6. Enter a Name (e.g., “IndexHighFragmentationTables”).

  7. Click “Import”.

  8. Navigate to the first line of code starting with “workflow” (below the comments).

  9. Replace the workflow name “Update-SQLIndexRunbook“ with the name of your Runbook (e.g., “IndexHighFragmentationTables”).

  10. Click “Save”.

Step 4: Test and publish the Runnbook

  1. Select tab “Test”.

  2. On the left side enter the parameters:
    SQLSERVER: The host name of the SQL Server
    DATABASE: The name of the database
    SQLCREDENTIALNAME: The name of the SQL Server credentials (e.g., “ConnectDatabaseCredentials”)

  3. Click Start to test the Runbook manually.

  4. Once the test is completed successfully, click the “X” in the upper left corner to return to the editor. The browser shows a dialog box asking you to confirm this action.

  5. Click “Publish” and then “Yes”.

Step 5: Create a Schedule

  1. In the Azure portal, navigate to your Runbook.

  2. Under Resources, select Schedules.

  3. Click “Schedule”.

  4. Select a Scheudle or create a new one.

  5. Click “Parameters”.

  6. Enter the parameters:
    SQLSERVER: The host name of the SQL Server
    DATABASE: The name of the database
    SQLCREDENTIALNAME: The name of the SQL Server credentials (e.g., “ConnectDatabaseCredentials”)

  7. Click “OK”

  8. Click “OK”

  • No labels