Python Optimization Techniques

08-19-2011 09:03 AM
New Contributor II
Hi Forum Folk,

I am writing to ask for suggestions for speeding up my script.

I currently have a 2 tables in a File Geodatabase.  The first [TABLE1] has approximately 2000 records and the second [TABLE2] approximately 200000 records. [TABLE2] contains a foreign key from [TABLE1]

I am currently using a SearchCursor with a Where statement to retrieve the relevant records from [TABLE2] for each row of [TABLE1].  Even though it has been suggested by ESRI to perform this process, it is taking approximately 1-2 seconds for the SearchCursor to execute and return its result set.  Each result set consists of between 100-2000 records.

The execution time seems incredibly slow for this operation.  I feel I may be missing a tweak that would speed this up, is the SearchCursor performing any license checks or validation checks in the background each time it is executed?  I have written some code to load [TABLE2] into a python dictionary to perform the look up on the foreign key.  There was a marked speed up.

Your thoughts?
0 Kudos
0 Replies