Use of spatial functions in a query

A spatial index is used as a consideration in certain queries.

The Db2 optimizer considers a spatial index for use when a query contains one the following functions in its WHERE clause:

  • ST_Contains
  • ST_Crosses
  • ST_Distance
  • EnvelopesIntersect
  • ST_Equals
  • ST_Intersects
  • ST_Overlaps
  • ST_Touches
  • ST_Within

In addition, the expression to the right of the predicate must be equal to 1, except when ST_Distance is the function on the left. With the ST_Distance function, the predicate must be less than the numeric value that is on the right.