All Products
Search
Document Center

PolarDB:TrajGiST indexing

Last Updated:Mar 28, 2026

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]);
ParameterRequiredDescription
index_nameNoName of the index
table_nameYesName of the table containing the trajectory column
traj_colYesName of the trajectory column
operator_familyNoOperator 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, and ST_ndWithin.
Note TrajGiST supports single-column indexes only. Creating an index across multiple columns where some columns store non-trajectory data is not supported.

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 familyAxes coveredUse when
trajgist_ops_zzQueries filter on elevation only
trajgist_ops_ttQueries filter on time only
trajgist_ops_2dx, yQueries filter on 2D spatial extent only
trajgist_ops_2dtx, y, tQueries filter on both 2D spatial extent and time
trajgist_ops_3dx, y, zQueries filter on 3D spatial extent only
trajgist_ops_3dtx, y, z, tQueries need full spatiotemporal coverage; supports all queries supported by the other five operator families
trajgist_ops_multiMultiple bounding boxesQueries 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>);