Tools that honor the Maintain Spatial Index environment delete and re-create the spatial index of an enterprise geodatabase feature class, or keep it in place and update it, according to the setting.
Maintain Spatial Index allows you to control how the spatial index for enterprise geodatabase feature classes is managed during geoprocessing operations (such as Append and Delete_Features) that insert, update, or delete data in an existing feature class. When set to False, the spatial index of the target feature class is deleted prior to any insert, update, or delete operation. When processing is complete, the spatial index is re-created. When set to True, the spatial index of the output feature class is not deleted prior to the start of processing. It is kept in place during the insert, update, or delete operation and is automatically updated afterward. If the feature class being updated does not have a spatial index, nothing is done as far as the spatial index is concerned; a spatial index is not added. See The spatial grid index for more information on enterprise geodatabase spatial indexes.
- If the operation you are performing includes a large number of inserts, updates, or deletes relative to the total number of features in your feature class, leave Maintain Spatial Index set to False to potentially gain better performance.
- Performance of operations that include a small number of inserts, updates, or deletes relative to the total number of features in your feature class (for example, inserting 30 features into a feature class containing one million features) may be improved by setting Maintain Spatial Index to True and allowing the system to update the existing spatial index automatically.
- Checked—The spatial index is left in place and updated after processing.
- Unchecked—The spatial index is dropped before processing and re-created at the end. This is the default.
arcpy.env.maintainSpatialIndex = boolean_option
If True, the spatial index is left in place and updated after processing.
If False, the spatial index is dropped before processing and re-created at the end. This is the default.
import arcpy # Set the maintainSpatialIndex environment to True arcpy.env.maintainSpatialIndex = True