Saturday 29 August 2015

Adding layer to MXD from different SDE slows down ArcPy script


My python script looks at layers in an MXD, then does a couple of clip and measure operations and generates a PDF.


It works accurately and quickly (0.5-3 seconds) when all the layers in the MXD are from SDE database #1.


It works accurately and slowly (20-50 seconds) when one of the layers in the MXD is from SDE database #2 -- even though:



  • the analysis process is only happening on layers from SDE #1 -- the data from #2 is just there to look pretty

  • all the data is in the same projection



The only time that the script might be dealing with that particular layer is when the MXD and layer variables are first all defined. (Each of these layers -- Annexations, Customers, Pole -- are in SDE #1.)


mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, '*')[0]
lyrAnnexations = arcpy.mapping.ListLayers(mxd, "Annexations", df)[0]
lyrCustomers = arcpy.mapping.ListLayers(mxd, "Customers", df)[0]
lyrPoles = arcpy.mapping.ListLayers(mxd, "Pole", df)[0]

I rebuilt the MXD from scratch with the same layers, and saw the exact same issue. Add layer from SDE #2, the script is much slower. Take layer from SDE #2 out of the map, the script goes back to its original speed.


I asked the network/database guy if he knew what was going on, and he'd never seen anything like it. How can a layer that isn't involved in an analysis have any impact on performance, let alone slow it down 10x?





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...