Guidelines for choosing a spatial index grid size
The guidelines provided in this topic can help improve the performance of spatial queries when you have to manually calculate the size of a spatial grid index in Oracle and DB2.
Grid cell size impacts the size of the spatial index table. Setting up the spatial index means balancing the cell sizes—smaller cell sizes mean more cells per shape, which require more entries in the spatial index table.
If you are using third-party client applications, the applications and spatial data profiles can vary from one system to another. In these cases, you may need to experiment with the spatial index, trying different cell sizes and different grid-level configurations.
- Consider how many grid levels are needed and remember that the database optimizer scans the spatial index table once per grid level. Often, a single grid level is the best solution for a feature class despite the notion of distributing geometries evenly across many grid levels to minimize the spatial index entries.
- Use one grid level for pure point type feature classes and consider making the cell sizes large. Spatial queries generally process point geometries faster than other geometry types.
- Monitor the spatial index. Tuning a spatial index is difficult if the data changes frequently. Tuning depends on the structure of the spatial data. Periodically assess the spatial index as your spatial data changes.
- Base the spatial index on the application. Match the spatial index grid cell sizes to the extent of the application window. By doing so, the application is probably viewing exact entries in the spatial index table. This helps size the spatial index table suitably and reduces the amount of processing, because fewer candidate feature IDs must be evaluated against the feature table.
- For unknown or variable application windows, start by defining one grid level with a cell size three times the average feature extent size. Query the business table to obtain the average feature size with the following SQL statement:
SELECT (AVG(ST_MAXX.shape – ST_MINX.shape) + AVG(ST_MAXY.shape – ST_MINY.shape)) / 2 from <N>;
- Design the spatial table around spatial data categories such as type, geometry size, and distribution. Sometimes, a carefully designed feature class, using these categories, can substantially boost the performance of spatial queries.
If you create your data through ArcGIS Desktop, the spatial grid index is calculated for you. In most cases, these grid sizes should not need to be altered. However, if you find the grids are not meeting your needs, follow the same guidelines for choosing a spatial index grid size as you would for spatial tables created with third-party clients.
For more information about the DB2 Spatial Extender grid index, see the IBM DB2 Spatial Extender and Geodetic Extender User's Guide and Reference.