IBM Db2 Spatial Extender provides a three-tiered grid spatial index to allow applications to query the two-dimensional geographic data contained in a spatial column and quickly identify all geometries lying within a given extent.
The two-dimensional spatial index differs from the traditional hierarchical B-tree index provided by Db2. The B-tree index may not be applied to a spatial column because the two-dimensional characteristic of the spatial column requires the structure of a spatial index. For the same reason, you may not apply a spatial index to a nonspatial column, and a spatial index may not be applied to a composite column of any kind.
For this reason, the spatial index's CREATE INDEX syntax includes the additional USING clause, which directs Db2 to use the Spatial Extender's spatial index rather than a B-tree index. The full syntax is as follows:
CREATE INDEX <index_name> ON <table> (<spatial column>) USING db2gse.spatial_index (<grid level 1>, [grid level 2], [grid level 3])
The addition of the USING clause distinguishes the spatial index from the B-tree index. The db2gse schema name must qualify the spatial_index extension name because this statement does not follow the current function path.
Because of the simple nature of the data that a B-tree was designed to index, the database designer directs Db2 to create the index on one or more table columns. However, since spatial data is complex, it requires the designer to understand its relative size distribution. The designer must determine the optimum size and number of the spatial index's grid levels.
The grid levels ([grid level 1], [grid level 2], [grid level 3]) are entered by increasing cell size. Therefore, the second level must have a larger cell size than the first and the third a larger cell size than the second. The first grid level is mandatory, but you may disable the second and third with a zero value (0).
See the Db2 documentation in the IBM Knowledge Center for more information on spatial indexes.