TrajGiST is a GiST (Generalized Search Tree) index extension for trajectory data. Create a TrajGiST index on a trajectory column to accelerate spatial and temporal queries — including time-only, spatial-only, and combined spatial-temporal filters.
How it works
TrajGiST improves on standard GiST in two ways:
-
Better index cost estimation: When multiple indexes exist on a table, TrajGiST selects the most efficient one for a given query by more accurately estimating index overhead.
-
Upward compatibility: TrajGiST can use a partial index — one that covers fewer dimensions than the query requires — to filter out non-matching trajectories before the exact computation runs. For example, if an index exists on the
taxis only and you run a query usingST_{2DT}Intersects, the index filters out trajectories outside the specified time range first, even though it cannot produce the final exact result on its own.
Create a TrajGiST index
CREATE INDEX [index_name] ON table_name USING TRAJGIST(traj_col [operator_family]);
| Parameter | Required | Description | Default |
|---|---|---|---|
index_name |
No | Name of the index | Auto-generated |
table_name |
Yes | Table that contains the trajectory column | — |
traj_col |
Yes | Name of the trajectory column | — |
operator_family |
No | Operator family that determines which axes the index covers | trajgist_ops_multi |
Use the ganos.trajectory.index_split_config parameter to specify the operator family when configuring the index split behavior.
The index accelerates queries that use operators and the following functions: ST_ndIntersect, ST_ndDWithin, ST_ndContains, and ST_ndWithin.
Choose an operator family
Each operator family determines which axes the index covers and therefore which queries benefit from it. Choose the operator family that matches the dimensions your queries use.
| Operator family | Axes indexed | Accelerates queries on |
|---|---|---|
trajgist_ops_z |
z |
Elevation dimension only |
trajgist_ops_t |
t |
Time dimension only |
trajgist_ops_2d |
x, y |
Spatial (2D) dimensions only |
trajgist_ops_2dt |
x, y, t |
Spatial (2D) + time dimensions |
trajgist_ops_3d |
x, y, z |
Spatial (3D) dimensions only |
trajgist_ops_3dt |
x, y, z, t |
All queries supported by the preceding five operator families |
trajgist_ops_multi |
Multiple bounding boxes | All queries; higher index creation time and storage cost |
Guidance:
-
Use
trajgist_ops_2dtortrajgist_ops_3dtfor most production workloads that combine spatial and time filters. -
Use
trajgist_ops_multi(the default) when query patterns are mixed and you want a single index to cover all cases — at the cost of more storage and a longerCREATE INDEXruntime. -
Use a single-axis family (
trajgist_ops_t,trajgist_ops_z,trajgist_ops_2d) when your queries consistently filter on only one dimension and index size or creation time is a concern.
Examples:
Index on the t axis only (for queries that filter by time):
CREATE INDEX traj_t_idx ON trips USING TRAJGIST(traj trajgist_ops_t);
Index on x, y, and t axes (for queries that combine spatial and time filters):
CREATE INDEX traj_2dt_idx ON trips USING TRAJGIST(traj trajgist_ops_2dt);
Default multi-bounding-box index:
CREATE INDEX traj_idx ON trips USING TRAJGIST(traj);
Limitations
TrajGiST supports indexing a single trajectory column only. Composite indexes that span multiple columns — where one or more columns are not of the trajectory type — are not supported.