When I run the following script it just spins and spins then arcmap turns to "not responding". I'm trying to update a versioned parcel layer using a .mdb file. When I "quote" out the updatecursor everything seems to run fine and it seems to enter the edit session as well. Any ideas on what it could be? I'm stuck.
from time import strftime print "Start script: " + strftime("%Y-%m-%d %H:%M:%S") import arcpy from arcpy import env sourceFC = r'M:\ParcelDatabase\...\Feb_2016_Ownership' sourceFieldsList = ["PARCEL","SITUS", "CURRENT_OWNER", "CO_OWNER", "OWNER_MAILADDR", "OWNER_CITY_STATE", "OWNER_ZIPCODE", "TAX_DISTRICT", "TAX_CODE", "SEC", "TOWNSHIP", "RANGE", "LEGAL"] # Use list comprehension to build a dictionary from a da SearchCursor valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)} arcpy.env.workspace = r"Database Connections\parcelpubdelete.sde" updateFC = r"Database Connections\...\ArcGISSDE.SDE.TaxParcel" updateFieldsList = ['PARCELID','SITEADDRESS','OWNERNME1', 'OWNERNME2', 'PSTLADDRESS', 'PSTLCITY', 'ZIPCODE', 'TAX_DIST', 'TAX_CODE', 'SEC', 'TWN', 'RGE', 'PRPRTYDSCRP'] edit = arcpy.da.Editor(r"Database Connections\parcelpubdelete.sde") edit.startEditing(False, True) edit.startOperation() print "entered edit session" with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows: for updateRow in updateRows: # store the Join value of the row being updated in a keyValue variable keyValue = updateRow[0] # verify that the keyValue is in the Dictionary if keyValue in valueDict: # transfer the values stored under the keyValue from the dictionary to the updated fields. for n in range (1,len(sourceFieldsList)): updateRow= valueDict[keyValue][n-1] updateRows.updateRow(updateRow) del valueDict edit.stopOperation() edit.stopEditing(True) print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")
Thanks for the info Joshua. I started it again this morning and it ran about 1,000/min til about 5,000 then slowed up a bit, at ~7000 it just stopped. There's no message and I can't click on anything, it just froze... We're not using parcel fabric.
OK. Seeing a parcel fabric is not involved, and the performance does degrade over time, this seems to generally fit into other discussions/complaints on GeoNet about update cursors on medium to large datasets.
A couple of ideas come to mind. First, can you go with multiuser_mode as False? If so, does that make a difference. Second, even though you have with_undo as False, you are still trying to update ~10,000 in one operation. You could use one edit session but chunk it up into multiple edit operations. In effect, iterate over the records committing the updates after every 1000-2000 records. Unfortunately with such an approach, the update cursor needs to be instantiated and released with each edit operation, so there is some work to ensure the records are ordered properly and divided up so records aren't missed.
Not sure if this will work with version data, but you may be better off doing a join and select those records that have changed.
Workflow: