Performance is slower after using Reconcile/Post

641
3
02-07-2018 05:33 AM
JordanMiller4
Occasional Contributor III

We have a Reconcile/Post routine that runs once a week on our enterprise geodatabase. When the script runs and finishes the editing performance is painful. The features load very quickly outside of editing but when we begin editing the performance drop 200%. 

import arcpy, time, smtplib, os
deleteVersions = True
reconcileLog = r'C:\temp\Reconcile_Log.txt'

# set the workspace
arcpy.env.workspace = 'Database Connections/SDE.sde'

# Set a variable for the workspace
adminConn = arcpy.env.workspace

# Block new connections to the database.
print("The database is no longer accepting connections")
arcpy.AcceptConnections(adminConn, False)

# Wait 15 minutes
#time.sleep(900)

# Disconnect all users from the database.
print("Disconnecting all users")
arcpy.DisconnectUser(adminConn, "ALL")

# Get a list of versions to pass into the ReconcileVersions tool.
print("Getting list of all versions")
versionList = arcpy.ListVersions(adminConn)

for version in versionList:
    if 'default' in version.lower():
        if 'dbo' in version.lower():
            defaultVersion = 'dbo.DEFAULT'
        elif 'sde' in version.lower():
            defaultVersion = 'sde.DEFAULT'


# Execute the ReconcileVersions tool.
print("Reconciling/posting/deleting all versions")
if deleteVersions:
    try:
        arcpy.ReconcileVersions_management(adminConn, "ALL_VERSIONS", defaultVersion, versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "DELETE_VERSION", reconcileLog)
    except:
        reconcileMessage = "Reconcile failed:  " + arcpy.GetMessages() + ".  Check reconcilelog.txt file in the " + str(reconcileLog)
        arcpy.AddWarning(reconcileMessage)
        pass
else:
    try:
        arcpy.ReconcileVersions_management(adminConn, "ALL_VERSIONS", defaultVersion, versionList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION", reconcileLog)
    except:
        reconcileMessage = "Reconcile failed:  " + arcpy.GetMessages() + ".  Check reconcilelog.txt file in the " + str(reconcileLog)
        arcpy.AddWarning(reconcileMessage)
        pass
print("Completed Reconcile & Post")

# Run the compress tool. 
print("Running compress")

arcpy.Compress_management(adminConn)
print("Compress Completed")

# Allow the database to begin accepting connections again
print("Allow users to connect to the database again")
arcpy.AcceptConnections(adminConn, True)

print("Starting Rebuild Indexes")
# Get a list of all the datasets the user has access to.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListTables() + arcpy.ListFeatureClasses() + arcpy.ListRasters()

# Next, for feature datasets get all of the datasets and featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets("", "Feature"):
    arcpy.env.workspace = os.path.join(adminConn,dataset)
    dataList += arcpy.ListFeatureClasses() + arcpy.ListDatasets()

# Get the user name for the workspace
userName = arcpy.Describe(adminConn).connectionProperties.user.lower()

# remove any datasets that are not owned by the connected user.
userDataList = [ds for ds in dataList if ds.lower().find(".%s." % userName) > -1]

# Execute rebuild indexes
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.RebuildIndexes_management(adminConn, "SYSTEM", userDataList, "ALL")
print('Rebuild Complete')

# Update statistics on the system tables
print("Updating statistics on the system tables")
# Execute analyze datasets
# Note: to use the "SYSTEM" option the workspace user must be an administrator.
arcpy.AnalyzeDatasets_management(adminConn, "SYSTEM", userDataList, "ANALYZE_BASE","ANALYZE_DELTA","ANALYZE_ARCHIVE")
print("Analyze Complete")

print("Finished.")

Mapping Software: Version 10.6

ArcGIS Server

Portal for ArcGIS

Two ArcGIS Web Adaptors

SQL Server 2012

Operating System

Windows Server 2012 R2

0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Jordan,

What is the state of your geodatabase after you run the script?  Have you tried compressing to a state of 0 to see if the issue still resides?  Compressing to a state of 0 will require deleting all versions.

JoeBorgione
MVP Emeritus

I sent this link to another colleague; he's wondering about the statistics for the business tables themselves. You are updating stats for system tables only.  Just a thought.

That should just about do it....
TinaMorgan1
Occasional Contributor II

Check the geoprocessing metadata in the GDB_ITEMS table.  When geoprocesses are ran on enterprise data, the process metadata is stored in the GDB_ITEMS table.  Over time this can build up.

Here is an article on how to do delete the metadata.  

How To: Delete geoprocessing history from a geodatabase