If you were a keen scripter you could probably write a much faster change detector in Python using the SET datatype.You have to load the sets of course, using a SearchCursor and creating a dictionary using the key. This takes a few seconds, but the result is definitely in memory.The set comparison takes milliseconds.Then you have to painfully write out the difference records using a layer. Depending on how many changes this can take a few minutes, or in your case, an update script can loop through the list.How large are your tables, and how many differences do you have?For an idea, I do a comparison of two featureclasses of polygons containing 2.45 million records.Last month there were 11616 changes, 1516 deletions and 2270 new records which are written out to new featureclasses.It takes around 40 minutes to run.Here is another example.When creating layer definition views you MUST index by the key for the SQL query to work in human time.#NAME: buildDeltaLYRs.py
#AUTHOR: Kevin Bell
#EMAIL: kevin.bell@slcgov.com
#DATE: 20071207
# edited by KimO
#PURPOSE: create adds/deletes layer files by comparing 2 point
# feature classes shape and attributes. If the shape has
# not changed, but any of the attributes have, the feature
# will show as a delete, and an add.
#RECOMMENDED SYMBOL: adds.lyr = green plus, deletes.lyr = red X
# (this allows for nice stacking)
#NOTE: __buildDict method has hard coded primary key and attribute names.
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
def buildDeltaLayers(inFC1, inFC2):
'''build an adds and deletes lyr for a given chrono FC '''
d1 = __buildDict(inFC1)
d2 = __buildDict(inFC2)
compareList = __valuesChanged(d1,d2)
__makeLYR(inFC1, compareList, "deletes")
print "...deletes.lyr is complete."
d1 = __buildDict(inFC2)
d2 = __buildDict(inFC1)
compareList = __valuesChanged(d1,d2)
__makeLYR(inFC2, compareList, "adds")
print "...adds.lyr is complete."
def __valuesChanged(dict1, dict2):
'''get a list of keys from one dict if a cooresponding dict's values are different '''
outList = [key for key in set(dict1.keys() + dict2.keys()) if dict1.get(key) != dict2.get(key)]
return outList
def __buildDict(inputFC): #-----BEWARE OF HARDCODED PRIMARY KEY AND ATTRIBUTES BELOW!!!!!
'''Build a dictionary of the primary key, and it's fields'''
d = {}
cur = gp.SearchCursor(inputFC)
row = cur.Next()
while row:
d[row.FP] = [row.Shape.Centroid, row.LUMENS, row.WATTS, row.TYPE, row.OWNER, row.RATE]
row = cur.Next()
del cur
return d
def __makeLYR(fc, inList, outLyrName):# BEWARE OF HARDCODED PRIMARY KEY BELOW
'''given a list, return a LYR file'''
wc = str(tuple(inList))
whereclause = "FP IN " + wc # <----IF DATA ISN'T FILE GDB, YOU MAY NEED QUOTES/BRACKETS
gp.MakeFeatureLayer_management (fc, outLyrName, whereclause)
gp.SaveToLayerFile_management (outLyrName, outLyrName +".lyr")
#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
print "----------- building adds/deletes layer files ----------------"
import arcgisscripting, time
startTime = time.clock()
gp = arcgisscripting.create()
gp.workspace = r"F:\Temp\streetLightCompare.gdb"# <----BEWARE OF HARDCODED WORKSPACE !!!!!
gp.OverwriteOutput = 1
#o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
buildDeltaLayers("SEP07","OCT07") #<-------------------BEWARE OF HARDCODED FEATURE CLASSES !!!!!
#o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o
print "Your adds/deletes lyr's are in:"
print str(gp.workspace)
del gp
print "--------------------------------------------------------------------------------------------"
stopTime = time.clock()
elapsedTime = stopTime - startTime
print "elapsed time = " + str(round(elapsedTime, 1)) + " seconds"