infobleep

Why would my script run slower than the Select By Attributes window?

Discussion created by infobleep on Sep 27, 2011
Latest reply on Sep 28, 2011 by infobleep
Hi there

I've created the below script which allows me to select features and have imported it into an ArcToolBox, with it set to run in the foreground. My reason for doing this is that I wish to be able to edit the script easily when changing layer or table names.

The problem I am finding with the interactive select by attribute window, is that I have to navigate through a rather long drop down list of layers and when ever I switch layers it helpful clears my SQL statement. Therefore I end up having to retype it even though the statements are often very similar.

However when I run the below code to select just 65 records out of over 61000, it is taking anything from 9 to 23 seconds, where as the interactive method takes under 2 seconds. Can anyone tell me what is cause this lag? Am I doing something wrong and if not, is there another way I can achieve this?
import arcpy
arcpy.SelectLayerByAttribute_management ("Full areas polygon layer outline only v5", "NEW_SELECTION", " \"AREA_NAME\" = 'AREA 4' ")
I may eventually use the arcpy.GetParameterAsText to allow me to change the inputy variable for the area_name and create scripts for other layers. However it's not saving me time if it takes 10-20 seconds each time.

Kind regards

Tim

Outcomes