SelectLayerByLocation very slow on 1st run fast on 2nd run

Discussion created by AntoJK on Sep 22, 2011
Latest reply on Sep 27, 2011 by AntoJK

I am using the following line of code to select some features from 2 different layers.

 arcpy.SelectLayerByLocation_management(inputLayer, "INTERSECT", selectFeatures, "", "NEW_SELECTION")

It works correctly, but when it is first ran it is really slow but the second time it is run it performs the task a lot faster. It doesn't matter which layer I run the task on first, the first run is always very slow and any subsequent runs are faster.

Does anybody know why this happens or a way to make the first run the same speed as the following runs?

Thanks for any tips.