The SE_SpatialKey() function
The SE_SpatialKey() function generates a sort key for an ST_Geometry. A sort key is a numeric value that can be used to sort spatial objects according to their proximity to one another.
The sort key is computed by applying the Hilbert space-filling curve algorithm to the center point of an object's bounding box.
Syntax
SE_SpatialKey(g1 ST_Geometry)
Return type
A numeric sort key, as an INT8
Example
Create and populate a cities table
containing the names and locations of world cities:
CREATE TABLE cities (name varchar(255),
locn ST_Point);
LOAD FROM cities.load INSERT INTO cities;
Create
a clustered functional B-tree index. This rearranges the table data,
placing it in spatial key sort order. R-tree indexes,
provides information about using indexes, in particular, R-tree indexes.
For example:
CREATE CLUSTER INDEX cbt_idx ON cities (SE_SpatialKey(locn));
Create
an R-tree index with the NO_SORT option:
CREATE INDEX locn_idx ON cities (locn ST_Geometry_ops)
USING RTREE (BOTTOM_UP_BUILD='yes', NO_SORT='yes');
Drop
the B-tree index; it is no longer needed:
DROP INDEX cbt_idx;