Spatiotemporal indexes

更新时间:
复制 MD 格式

The Lindorm Ganos spatiotemporal service extends the primary key index and secondary index capabilities of Lindorm to accelerate spatiotemporal queries. A spatiotemporal query is a query with conditions that include a spatial column, such as a column of latitude and longitude coordinates or a column of the Geometry type. The query can also be based on a combination of spatial and temporal columns, such as a Geometry column and a time column.

Z-ORDER index

When you create a primary key index or secondary index, you can use the Z-ORDER function to index a spatial column or a combination of spatial and temporal columns. The Z-ORDER function returns an encoded value, known as a Z-ORDER encoding or spatiotemporal encoding, that becomes part of the primary key or secondary index. A spatiotemporal index is not independent. It is embedded in a Lindorm primary key or secondary index to accelerate spatiotemporal queries.

Z-ORDER function-based index classifications

Z-ORDER primary key index

When the Z-ORDER encoding is part of the primary key index, the index is a Z-ORDER primary key index. For example: PRIMARY KEY(Z-ORDER(g)).

Z-ORDER secondary index

When the Z-ORDER encoding is part of the secondary index, the index is a Z-ORDER secondary index. For example: Z-ORDER(g).

For more information about how to create a Z-ORDER index, see Create a spatiotemporal index.

Z-ORDER function description

Lindorm Ganos automatically calculates spatiotemporal encodings based on the input parameters of the Z-ORDER function. The following table lists the Z-ORDER function types, parameters, and scenarios.

Note

If two spatial objects are very close to each other (at the centimeter level), the Z-ORDER function may generate the same spatiotemporal encoding.

Type

Parameter description

Scenarios

Z-ORDER(Point) or Z-ORDER(X, Y)

  • A column of the Point type

  • Consists of a longitude column (x) and a latitude column (y)

Creates an index for point data to accelerate queries with a spatial range condition.

Z-ORDER(Point, Time) or Z-ORDER(X, Y, Time)

  • Consists of a column of the Point type and a time column

  • Consists of a longitude column (x), a latitude column (y), and a time column

Creates an index for point data with time to accelerate queries with both spatial and time range conditions.

Z-ORDER(LineString) or Z-ORDER(Polygon)

  • A column of the LineString type

  • A column of the Polygon type

Creates an index for LineString or Polygon data to accelerate queries with a spatial range condition.

Z-ORDER(LineString, Time) or Z-ORDER(Polygon, Time)

  • Consists of a column of the LineString type and a time column

  • Consists of a column of the Polygon type and a time column

Creates an index for LineString or Polygon data with time to accelerate queries with both spatial and time range conditions.

Grid secondary index

Important

The grid secondary index feature is supported only by LindormTable version 2.6.5 or later.

When you apply the S2 function to a Geometry column during index creation, LindormTable automatically builds a grid secondary index. The S2 function supports the POLYGON, MULTIPOLYGON, LINESTRING, and MULTILINESTRING types. A grid secondary index filters and computes data based on grids.

A grid secondary index uses the Google S2 algorithm to divide a space into uniformly sized grids called S2Cells. Each grid has a unique ID called an S2CellID. The index records which polygons intersect with each grid.

S2 index function description

Syntax

The S2 function takes a geometry object and a precision level as input, calculates the grids that the geometry covers at the specified precision, and returns a collection of grid IDs (S2CellIDs). For more information about how to create a grid index, see Create a spatiotemporal index.

Set<Long> S2(String geomColumnName, int level)

Parameter description

Parameter

Description

geomColumnName

The name of a column of the Polygon type (POLYGON or MULTIPOLYGON) or the LineString type (LINESTRING or MULTILINESTRING). The spatial data in this column must use WGS84 coordinates.

Important

The LineString type (LINESTRING or MULTILINESTRING) is supported only by LindormTable of version 2.6.7.5 or later. If you cannot upgrade LindormTable in the console, contact Lindorm technical support (DingTalk ID: s0s3eg3).

level

The precision level of the S2 grid. Valid values: [1, 30].

Index selection

Scenarios for Z-ORDER indexes

Z-ORDER indexes provide effective filtering for spatial point data. If your queries involve spatial point positions, create a Z-ORDER index with the appropriate function. For more information, see Z-ORDER function description.

Common scenarios for Z-ORDER indexes:

Z-ORDER indexes also support basic filtering for LineString or Polygon data. For example:

  • For LineString types: Query roads within a certain distance of a location. Each road is a LINESTRING or MULTILINESTRING.

  • Polygon Type: Find business districts within a specified area. Business districts are represented by POLYGON or MULTIPOLYGON geometries.

Scenarios for grid secondary indexes

Compared with Z-ORDER indexes, grid secondary indexes provide better filtering for LineString or Polygon data. For non-aggregate queries, a grid secondary index filters out irrelevant grids to accelerate query performance. For example:

  • Geofence monitoring: Perform real-time queries to find which geofences a trajectory point falls into. You can retrieve results from millions of geofence data records in milliseconds.

  • Proximity query: Perform real-time queries to find business districts within a certain radius of a location.

Grid indexes can be updated at any time to store statistical data, enabling fast aggregate statistics based on grids. For example:

  • Count statistics: Count the number of business districts or trajectories per grid.

  • Regional attribute statistics: Calculate metrics such as vegetation coverage or total transaction volume per grid.