ArcGIS Server Banner

Setting spatial indexes

Setting spatial indexes

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback

About setting a spatial index

The spatial index is used to quickly locate features when you display, edit, or query data. Therefore, an appropriate spatial index is important, especially when you're working with large amounts of data.

Spatial indexes work differently depending on the data source. File and ArcSDE geodatabases in DB2, ArcSDE geodatabases in Oracle and SQL Server that use binary geometry storage, and ArcSDE geodatabases in Oracle that use ST_Geometry storage use a system of up to three grids as the spatial index. Personal geodatabases use a single grid. A grid is defined by a size, referred to as the grid size. This is the size of each cell in the grid, specified in the units of the feature class's coordinate system. Oracle Spatial, Informix, and PostgreSQL do not use grid sizes—they use an R-tree index. Similarly, with SQL Server spatial types, the spatial index does not use grids.

This topic discusses how ArcGIS manages spatial indexes and what you should do to help maintain them.

How ArcGIS maintains indexes in file and ArcSDE geodatabases

ArcGIS automatically rebuilds the spatial index at the end of certain operations in file and ArcSDE geodatabases to ensure the index is optimal. The following explains how ArcGIS manages the spatial index:

When to update the index in file and ArcSDE geodatabases

Because ArcGIS maintains the spatial index in file and ArcSDE geodatabases, you seldom need to manually set or recalculate the index. Changing or recalculating the index is required only in the following rare situations:

This topic has so far mostly discussed using the default grid sizes calculated by ArcGIS for spatial grid indexes. In most circumstances, the default grid size will be appropriate for fast spatial queries. However, depending on the characteristics of your data and how you access it, it may not be the optimal size. Setting your own grid sizes may result in better performance. Finding better grid sizes involves experimenting with different sizes and running performance tests each time to observe the effects. However, you may not be able to improve performance—the existing grid size may already be optimal.

If you manually entered grid sizes and would like to revert to a size provided by ArcGIS, you can recalculate a new grid size at any time. Click the Recalculate button on the Index tab of the Feature Class Properties dialog box. ArcGIS can also calculate an appropriate grid size with the Calculate Default Spatial Grid Index geoprocessing tool, although this provides the same size you would get with the Recalculate button.

If you are using an R-tree spatial index or Microsoft SQL Server spatial type indexes, grids are not used and, therefore, there is no need to recalculate grids.

Spatial indexes in personal geodatabases

Whenever you create a feature class in a personal geodatabase, whether with the New Feature Class wizard, a geoprocessing tool, or any other method, you must specify a grid size or accept the default grid size of 1,000. Once a feature class is created, the grid size cannot be modified. Since the grid size is permanent, ArcGIS does not automatically recalculate its size at the end of certain operations as it does with file and ArcSDE geodatabases.

Keep in mind that the default size of 1,000 is specified in the units of the feature class's coordinate system. This means if your feature class is in a geographic coordinate system and you use the default, all features will be placed in a single grid cell. This will provide no benefits to performance.

If you suspect a poor grid size is causing slow performance, you can try reloading the data to a new feature class with an optimal grid size:

  1. Use the Calculate Default Spatial Grid Index geoprocessing tool to find a good grid size for the feature class. This tool outputs up to three optimal grid sizes. You will use the Default Spatial Grid Index 1 value in the next step.
  2. Create a new, empty feature class with the New Feature Class wizard. In the wizard, specify the same coordinate system and fields as in the feature class you're reloading (the wizard allows you to import these). When you get to the list of fields, click on the Shape field and, for the Grid 1 property, specify the new grid size. Proceed to complete the wizard.
  3. Use the Append geoprocessing tool to import all records from the source data to the new, empty feature class.

How to modify a spatial grid index

NOTE: Modifying the spatial index of a feature class in an ArcSDE geodatabase is available with ArcInfo and ArcEditor only.

These steps apply only to file geodatabases and feature classes in the following ArcSDE geodatabases and geometry storage types:

  1. In the Catalog tree, right-click the file or ArcSDE geodatabase feature class whose spatial index you want to modify. Note that you cannot modify the spatial index of a feature class in a personal geodatabase.
  2. Click Properties.
  3. Click the Indexes tab.
  4. To have ArcGIS set the grid size for you, click Recalculate.
  5. To set your own grid sizes, click Edit and enter one or more grid sizes, and click OK.
  6. Click OK to build the spatial index and close the Feature Class Properties dialog box.

Tips

  • If you are unsure whether to recalculate the spatial index, you can always check to see if it's necessary. Click the Recalculate button to see how ArcGIS would update the grid sizes. If the new sizes are roughly the same as the current sizes, you do not need to update the index and can close the dialog box. If the sizes are different, you can click OK to rebuild the index with the new sizes.
  • When you use the Recalculate button to update the spatial index of an ArcSDE feature class that is enabled for archiving, the spatial index on the archive table is automatically recalculated.
  • When you use the Edit button to alter the spatial index of the feature class by providing specific grid values, if you want to also recalculate the spatial index on the archive table, you must use the ArcSDE sdelayer command. Consult the ArcSDE Administration Command Reference for details.
  • Building a new spatial index for an ArcSDE feature class is a server-intensive operation—it should not be done on large feature classes when a large number of users are logged in to the server.
  • If this functionality is inactive, it is likely you are using a geometry storage type that does not use spatial grid indexes.