All Products
Search
Document Center

PolarDB:TrajGiST indexing

Last Updated:Mar 28, 2026

TrajGiST is an extension to GiST (Generalized Search Tree) indexing, designed for trajectory data columns. Create a TrajGiST index to accelerate spatial-temporal queries on trajectory data stored in PolarDB.

How it works

TrajGiST stores multidimensional bounding boxes for trajectory data. When a query runs, the index filters trajectories by checking whether their bounding boxes overlap the query range—only on the axes the index covers. This bounding-box approach enables two key capabilities:

  • More accurate cost estimation: When multiple indexes exist, TrajGiST selects the most efficient one based on query cost estimates.

  • Upward compatibility: If the index covers only a subset of the dimensions a query needs, TrajGiST still uses the index as a coarse-grained pre-filter on the covered axes. For example, an index on the t axis only can pre-filter trajectories outside a specified time range, even when the query calls the ST_{2DT}Intersects function.

Create a TrajGiST index

CREATE INDEX [index_name] ON table_name USING TRAJGIST(traj_col [operator_family]);
ParameterRequiredDescription
index_nameOptionalThe name of the index.
table_nameRequiredThe name of the table that contains the trajectory column.
traj_colRequiredThe name of the trajectory column.
operator_familyOptionalThe operator family that defines which axes the index covers. Default: trajgist_ops_multi. Use the ganos.trajectory.index_split_config parameter to specify the operator family.

The index accelerates queries that use these functions: ST_ndIntersect, ST_ndDWithin, ST_ndContains, and ST_ndWithin.

Note TrajGiST indexes a single column only. It does not support multi-column indexes that mix trajectory columns with other data types.

Choose an operator family

Each operator family defines which axes the index covers. Select the operator family that matches the axes your queries use.

Operator familyAxes coveredUse when your queries filter on...
trajgist_ops_zzz axis only
trajgist_ops_ttt axis (time) only
trajgist_ops_2dx, yx and y axes only
trajgist_ops_2dtx, y, tx, y, and t axes
trajgist_ops_3dx, y, zx, y, and z axes
trajgist_ops_3dtx, y, z, tAll four axes. Supports queries covered by the preceding five operator families.
trajgist_ops_multiMultiple bounding boxesMixed or unpredictable query patterns. Accelerates queries, but takes more time and storage to build.

Decision guide:

  • If all your queries filter on a known set of axes, pick the operator family that matches exactly (for example, trajgist_ops_2dt for x, y, and t).

  • If query patterns vary or you query multiple dimension combinations, use trajgist_ops_multi (the default).

  • An index on fewer axes still provides a partial speedup for queries that use more axes, because TrajGiST applies the index as a pre-filter for the covered dimensions.

Use the index in queries

The index is used automatically when you call the supported functions (ST_ndIntersect, ST_ndDWithin, ST_ndContains, and ST_ndWithin).

TrajGiST also supports upward compatibility: if the index covers fewer axes than a query needs, it still applies as a coarse-grained pre-filter on the covered axes. Only trajectories that pass the pre-filter proceed to full evaluation, which reduces the number of rows scanned.