GiST indexing
更新时间:
复制 MD 格式
Create a Generalized Search Tree (GiST) index on a trajectory data column to accelerate spatial queries on that column.
How it works
The following functions automatically use the GiST index when one is available:
ST_ndIntersectST_ndDWithinST_ndContainsST_ndWithin
Syntax
CREATE INDEX [index_name] ON table_name USING GIST(traj_col [operator_family]);| Parameter | Required | Description |
|---|---|---|
index_name | No | Name of the index |
table_name | Yes | Name of the table that contains the trajectory column |
traj_col | Yes | Name of the trajectory column |
operator_family | No | Operator family that determines which axes are indexed. Default: trajgist_ops_3dt |
The default operator family trajgist_ops_3dt indexes all four axes (x, y, z, and t) and supports every query type. If your queries consistently target a smaller set of axes, specify a narrower operator family. Fewer indexed dimensions generally produce faster queries.
Supported operator families
| Operator family | Indexed axes | Supported query types |
|---|---|---|
trajgist_ops_z | z | z-axis queries |
trajgist_ops_t | t | t-axis queries |
trajgist_ops_2d | x, y | x- and y-axis queries |
trajgist_ops_2dt | x, y, t | x- and y-axis queries; t-axis queries; x-, y-, and t-axis queries |
trajgist_ops_3d | x, y, z | x- and y-axis queries; z-axis queries; x-, y-, and z-axis queries |
trajgist_ops_3dt | x, y, z, t | All query types supported by the preceding five operator families |
Examples
The following examples create indexes optimized for specific query patterns.
-- Index on the t axis only — for time-range queries
CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_t);
-- Index on the x and y axes — for 2D spatial queries
CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_2d);
-- Index on the x, y, and t axes — for spatiotemporal queries without elevation
CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_2dt);该文章对您有帮助吗?