TrajGiST is an extension to GiST (Generalized Search Tree) indexing for trajectory data columns. It improves index selection accuracy and supports partial index filtering, so a t-axis-only index can still pre-filter rows for queries that span multiple dimensions.
How it works
TrajGiST improves on standard GiST indexing in two ways:
Better index selection: When multiple indexes exist on a table, TrajGiST more accurately estimates index overhead and selects the most efficient index.
Upward compatibility: When an index covers fewer dimensions than a query needs, TrajGiST still uses the index to filter rows coarsely. For example, an index built only on the t axis can pre-filter trajectories outside a specified time range, even for a query that calls
ST_{2DT}Intersects.
Create a TrajGiST index
CREATE INDEX [index_name] ON table_name USING TRAJGIST(traj_col [operator_family]);| Parameter | Required | Description |
|---|---|---|
index_name | No | Name of the index |
table_name | Yes | Name of the table containing the trajectory column |
traj_col | Yes | Name of the trajectory column |
operator_family | No | Operator family that determines which axes the index covers. Default: trajgist_ops_multi. Configure via the ganos.trajectory.index_split_config parameter. |
A TrajGiST index accelerates queries that use the following functions:ST_ndIntersect,ST_ndDWithin,ST_ndContains, andST_ndWithin.
Choose an operator family
Each operator family defines which axes the index covers and which queries it can accelerate. Choose the operator family that matches your query patterns — a narrower family builds faster and uses less storage than trajgist_ops_multi.
| Operator family | Axes covered | Use when |
|---|---|---|
trajgist_ops_z | z | Queries filter on elevation only |
trajgist_ops_t | t | Queries filter on time only |
trajgist_ops_2d | x, y | Queries filter on 2D spatial extent only |
trajgist_ops_2dt | x, y, t | Queries filter on both 2D spatial extent and time |
trajgist_ops_3d | x, y, z | Queries filter on 3D spatial extent only |
trajgist_ops_3dt | x, y, z, t | Queries need full spatiotemporal coverage; supports all queries supported by the other five operator families |
trajgist_ops_multi | Multiple bounding boxes | Queries span diverse dimension combinations; provides the broadest acceleration but requires more time and storage to build |
If your queries consistently filter on a specific axis or dimension combination, choose the matching single-family option rather than trajgist_ops_multi. Use trajgist_ops_multi only when you cannot predict which dimension combinations your queries will use.
Example queries
The following examples show how TrajGiST indexes accelerate different query types. All examples use a table trips with a trajectory column traj.
Index covering x, y, and t axes
CREATE INDEX idx_trips_traj ON trips USING TRAJGIST(traj trajgist_ops_2dt);Spatial query accelerated by the index
-- The index filters rows by bounding box before evaluating exact containment
SELECT * FROM trips WHERE ST_ndContains(traj, <spatial_range>);Upward compatibility — coarse filtering with a t-axis-only index
-- Index covers only the t axis
CREATE INDEX idx_trips_t ON trips USING TRAJGIST(traj trajgist_ops_t);
-- TrajGiST uses the t-axis index to eliminate rows outside the time range first,
-- then evaluates the full spatiotemporal condition on the remaining rows
SELECT * FROM trips WHERE ST_ndIntersect(traj, <spatiotemporal_range>);