If I'm using an arcpy.da.UpdateCursor to search for an ObjectID and delete the entry/row, is it possible to walk the cursor backwards for sake of speed?
Knowing that my feature has recently been created and would be near the last index, would the cursor be faster with a for loop going backwards (if such a thing) and a break statement after the deletion?
Or is the cursor set up more like a set, and unordered by OID?
Cheers
Solved! Go to Solution.
As far as I know, there is no way tot walk the cursor backwards. But you can include a where clause in the cursors
with arcpy.da.UpdateCursor(your_table, "OBJECTID", "OBJECTID=12345") as cursor:
for row in cursor:
cursor.deleteRow()
I did a little test on an Enterprise geodatabase (albeit with a SearchCursor).
The execution time of the loop solution predictably depended on the position of the row in the table. This solution did not and also was a little quicker than the loop. Your mileage may vary, of course.
As far as I know, there is no way tot walk the cursor backwards. But you can include a where clause in the cursors
with arcpy.da.UpdateCursor(your_table, "OBJECTID", "OBJECTID=12345") as cursor:
for row in cursor:
cursor.deleteRow()
I did a little test on an Enterprise geodatabase (albeit with a SearchCursor).
The execution time of the loop solution predictably depended on the position of the row in the table. This solution did not and also was a little quicker than the loop. Your mileage may vary, of course.
Of course!
This will be optimal, thanks.