Select to view content in your preferred language

ArcGIS Server - Define a default workspace for every service instances

1366
4
Jump to solution
08-07-2018 11:14 AM
MaximeDemers
Frequent Contributor

Hi,

I have some geoprocessing services published to ArcGIS Server. I have noticed that every time a request is made, a great amount of time (1 to 3 seconds) is needed to establish the connection to the Geodatabase Entreprise workspace.

For instance, if I use a SearchCursor in a GP Service, a lot of time is spent setting arcpy.env.workspace. It's not faster to define the workspace in the SearchCursor in_table parameter.

I would like to know if it's possible to define a default workspace at the service instances level in order that when a service instance is created, the connection to a Geodatabase Entreprise workspace is made and kept open until the instance is closed?

Thank you!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
MatthewLofgren
Frequent Contributor
4 Replies
MatthewLofgren
Frequent Contributor

This may help? - Performance tips for geoprocessing services—Documentation | ArcGIS Enterprise 

The bit about "Use layers for project data"

MaximeDemers
Frequent Contributor

That's interesting! I'll try using layers as input rather than paths to datasets

0 Kudos
MaximeDemers
Frequent Contributor

After some testing, I confirm that using layer (.lyr) as the in_table parameter in arcpy.da.SearchCursor is much faster than using the path to the feature class.

However, to be able to use fields name tokens such SHAPE@ or SHAPE@JSON you have to create a new layer class with the arcpy.mapping module.

For instance:

layer_path = r"c:\\temp\\myLayer.lyr"

with arcpy.da.SearchCursor(arcpy.mapping.Layer(layer_path), ["*"]) as cursor:
    for row in cursor:
        print row
Jack_Zhang
Frequent Contributor

I have to give you a thumb up as none of ESRI's doc or webinar I have searched gave a clear example of how to use Layer as the input, because there're some many definition/interpolation of what a Layer is, not to mention have to convert it to Layer class using arcpy.mapping to in order to use the field tokens. thank you.