Home | Previous Page | Next Page   Using the R-Tree Secondary Access Method >

Performing Nearest-Neighbor Searches

If the DataBlade module you are using is set up for it, you can perform nearest-neighbor searches. For example, the IBM Informix Geodetic DataBlade module and the IBM Informix Spatial DataBlade module both provide nearest-neighbor search support.

After you create an R-tree index on the column on which you want to perform nearest-neighbor queries, you can use the functions that your DataBlade documentation identifies as nearest-neighbor functions to perform nearest-neighbor queries.

Nearest-neighbor searches return results in order of increasing distance from the specified object or location. Without any other restriction, a nearest-neighbor query returns a result for all rows returned by the query. Often, you will want to restrict the results, for example, using the FIRST n syntax to obtain just the first few results (as shown in the example below).

The WHERE clause of a nearest-neighbor query can include other qualifications, provided the clause is connected by AND.

A DataBlade module might provide more than one nearest-neighbor function. For example, the IBM Informix Spatial DataBlade module provides the SE_Nearest and SE_NearestBBox functions. The SE_Nearest function calculates precise distances between objects. SE_NearestBBox calculates distances as measured between objects' bounding boxes (envelopes). Because this calculation is simpler, SE_NearestBBox executes more quickly but might return objects in a different order depending on the actual shape of the objects.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]