TrajGisT indexes
TrajGiST indexing is an extension to GiST indexing. When you query trajectory data across multiple axes—spatial, vertical, and temporal—standard GiST indexes cannot efficiently estimate query costs or filter partial-axis results. TrajGiST extends GiST with better cost estimation and upward index compatibility, so the query planner selects the right index and partial-axis indexes still reduce scan costs.
How it works
TrajGiST performs better than GiST in the following ways:
-
Better cost estimation: TrajGiST provides a better method to estimate the overheads of indexes. When multiple indexes exist on a table, the query planner uses this cost estimate to select the most efficient index.
-
Upward index compatibility: If an accurate result cannot be obtained because the index does not provide sufficient information, you can still obtain a coarse-grained result by using an index-based scan. For example, if you create an index only on the t axis and then call
ST_{2DT}Intersects, the index filters out trajectories that do not fall within a specified time range before the exact check runs.
Create an index
CREATE INDEX [index_name] ON table_name USING TRAJGIST(traj_col [operator_family]);
| Parameter | Description | Required |
|---|---|---|
index_name |
Name of the index | No |
table_name |
Name of the table | Yes |
traj_col |
Name of the trajectory column | Yes |
operator_family |
Operator family that determines which axes are indexed. Default: trajgist_ops_3dt |
No |
TrajGiST supports single-column indexes on trajectory columns only. Multi-column indexes and indexes on non-trajectory columns are not supported.
Choose an operator family
Select the operator family that matches the axes used in your queries.
| Operator family | Indexed axes | Use when your queries filter on... |
|---|---|---|
trajgist_ops_z |
z | z axis only |
trajgist_ops_t |
t | time only |
trajgist_ops_2d |
x, y | 2D spatial only |
trajgist_ops_2dt |
x, y, t | 2D spatial and time |
trajgist_ops_3d |
x, y, z | 3D spatial only |
trajgist_ops_3dt |
x, y, z, t | any combination of all four axes (default) |
Accelerated functions
The index accelerates queries that are run by operators and the following functions:
-
ST_ndIntersect -
ST_ndDWithin -
ST_ndContains -
ST_ndWithin
If the index does not cover all axes used by the query, it still filters using the axes it does cover. The database then runs the exact check on the remaining trajectories.