ArcGIS uses spatial indexes to improve spatial query performance on feature classes. Identifying a feature, selecting features by pointing or dragging a box, and panning and zooming all require ArcMap to use the spatial index to locate features.
When you create an empty feature class* or import data to create a feature class in a geodatabase from ArcGIS, a spatial index is created on the feature class. The spatial index is used when querying and editing data.
*When you create empty feature classes in geodatabases in DB2, spatial indexes are not created.
Types of spatial indexes
Spatial indexes differ depending on the data source. Feature classes in the following geodatabase types use grid-based spatial indexes:
- Personal geodatabases
- File geodatabases
- Geodatabases in DB2
- Geodatabases in Oracle, if the feature class contains an Esri ST_Geometry or binary geometry storage field
- Geodatabases in SQL Server, if the feature class contains a binary geometry storage field
Feature classes in the following geodatabase types use R-tree spatial indexes:
- Geodatabases in Oracle, if the feature class contains an Oracle Spatial (SDO_Geometry) storage field
- Geodatabases in Informix
- Geodatabases in PostgreSQL
Feature classes in geodatabases in SQL Server that contain a geometry or geography storage field use a modified B-tree spatial index.
How ArcGIS maintains spatial indexes
ArcGIS automatically rebuilds the spatial index at the end of certain operations in file, enterprise, workgroup, and desktop geodatabases to ensure the index is optimal. The following explains how ArcGIS manages the spatial index:
- When you create an empty feature class with the New Feature Class wizard, a spatial index is created for file, workgroup, desktop, and all enterprise geodatabases except those in DB2 databases. The spatial index is used when editing, querying, or running the Load Data commands. In enterprise geodatabases in DB2, the spatial index is created after data is loaded into the empty feature class.
- If you import data from a personal geodatabase, shapefile, or coverage or import computer-aided drafting (CAD) or Smart Data Compression (SDC) data to a file, enterprise, workgroup, or desktop geodatabase, a spatial index is automatically computed for the new feature class.
- The spatial index is automatically rebuilt when you use the ArcCatalog Copy and Paste commands to copy a feature class from a personal geodatabase to a file, enterprise, workgroup, or desktop geodatabase. The spatial index is also rebuilt if you copy a feature class from Oracle Spatial, PostgreSQL, or Informix. If you copy a feature class from a file or enterprise geodatabase that uses a grid-based index (Oracle binary and ST_Geometry, SQL Server binary, or DB2) to another geodatabase that uses a grid-based index, the index is copied along with the source data and not rebuilt.
- When you use a geoprocessing tool that creates a feature class, the tool creates a spatial index based on the features in the new feature class.
- When you save edits or use the Load Data commands on a feature class that does not have a spatial index, a spatial index is created at the end of the Save Edit or Load Data operation.
- Compressed file geodatabase feature classes do not use the same type of spatial index used in uncompressed feature classes. When you compress a file geodatabase feature class, it's automatically reindexed. This index cannot be modified. When you uncompress the feature class, the same spatial index the feature class had before it was compressed is automatically reestablished.
When to update the spatial index
Because ArcGIS maintains the spatial index in file, enterprise, workgroup, and desktop geodatabases, you seldom need to re-create the spatial index manually. Re-creation of the spatial index is recommended only after you have added a large number of features that differ in size from the features that are already in the feature class. This applies to adding features in edit sessions only. For example, you may have started an edit session and manually added a large number of line features or used the Object Loader to load them. Many of the features you've added are either considerably longer or shorter than the features already in the feature class. To ensure that the spatial index will work optimally with the new features, it should be updated.
When you create a feature class in a personal geodatabase, whether with the New Feature Class wizard, a geoprocessing tool, or any other method, ArcGIS calculates the spatial index. The spatial index created on a feature class in a personal geodatabase is based on the horizon of the feature class coordinate system and will always be optimal; it cannot be modified.