arcpy.env.workspace assignment takes excessively long (3 minutes)

12-02-2014 12:39 PM
Occasional Contributor III

I wrote a script to determine how long it takes to set arcpy.env.workspace to a series of feature datasets within an enterprise geodatabase(SDE 10.2.2 on SQL Server 2012), and these are my results.  You can see that some of the assignments take longer than 3 minutes, and it's just assigning a workspace!

7.3149998188seconds to set EONGIS.SDE.faa as workspace

1.0720000267seconds to set EONGIS.SDE.mlquery as workspace

222.508000135seconds to set EONGIS.SDE.naturalhazards as workspace

79.6970000267seconds to set EONGIS.SDE.partnerfeeds as workspace

0.561000108719seconds to set as workspace

2.94499993324seconds to set EONGIS.SDE.Boundaries as workspace

221.398999929seconds to set EONGIS.SDE.naturalhazards2 as workspace

For reference, here is the script:

import arcpy, time

uri = r"C:\EsriEON\eon\publishing\connections\eon_connection.sde"

arcpy.env.workspace = uri

dsets = arcpy.ListDatasets()

for dset in dsets:

     start = time.time()

     arcpy.env.workspace = uri + "\\" + dset

     end = time.time()

     print str(end-start) + "seconds to set " + dset + " as workspace"

So obviously the naturalhazards feature dataset is the most problematic.  But so is partnerfeeds.  Naturalhazards2 is an exact copy of the original naturalhazards.  I created naturalhazards2 to see if there was some corruption in naturalhazards. 

Here's some contextual information...

My geodatabase is mostly feature datasets with feature classes inside, but also has some locators, and a toolbox.  There is nothing unique about any of the feature datasets except the data within them.  Each contains between 2 and 6 feature classes and that's it, and each is used as the source for some server map services.  Does anyone have any suggestions on why these times may vary so much?  How to troubleshoot why some may be taking longer than others?


0 Kudos
1 Reply
New Contributor

Thanks for running tests and putting some numbers to it. Would also love to know why this is a thing!

0 Kudos