ksshannon

Poor performance with FileGDB and AddField_management

Discussion created by ksshannon on Nov 28, 2011
Latest reply on Dec 1, 2011 by csny490
I am getting poor performance adding fields to a feature class in a FileGDB.  This is a ArcGIS Server geoprocessing service and for each call, AddField is taking between 1.3 and 1.8 seconds per call.  With 25 fields to add (I don't know what they are ahead of time) it takes way too long to run for a service.  If I use in memory or shapefiles, it takes about 1/10 the time.  Is there a way to add multiple fields at once to avoid the overhead (I assume) of opening and closing the FileGDB?  Shape files and in memory features don't support all the functionality I need.  Below is a quick example straight from my arcpy console (the exec calls are for more accurate times):

>>> fc = 'C:\\Users\\kshannon\\Documents\\ArcGIS\\Default.gdb\\output'
>>> shp = C:\\Users\\kshannon\\Documents\\ArcGIS\\output.shp'
>>> gdb_code = 'start = time.clock()\narcpy.AddField_management(fc,new_field,"DOUBLE")\nprint("AddField:{0}".format(time.clock()-start))'
>>> shp_code = 'start = time.clock()\narcpy.AddField_management(fc,new_field,"DOUBLE")\nprint("AddField:{0}".format(time.clock()-start))'
>>> new_field = "NEW_FIELD"
>>> exec(shp_code)
AddField:0.683299860168

>>> exec(gdb_code)
AddField:1.4100630674


Neither feature is loaded in ArcMap.  The time gap grows quite a bit with 25-30 new Fields.  Any suggestions?

Outcomes