All Products
Search
Document Center

PolarDB:GiST indexing

Last Updated:Mar 28, 2026

Create a GiST (Generalized Search Tree) index on a trajectory column to accelerate spatial queries. The index speeds up queries that use ST_ndIntersect, ST_ndDWithin, ST_ndContains, and ST_ndWithin.

Syntax

CREATE INDEX [index_name] ON table_name USING GIST(traj_col [operator_family]);
ParameterRequiredDefaultDescription
index_nameNoName of the index
table_nameYesName of the table
traj_colYesName of the trajectory column
operator_familyNotrajgist_ops_multiOperator family that determines which axes the index covers. Use the ganos.trajectory.index_split_config parameter to configure the operator family.

Choose an operator family

The operator family determines which spatial dimensions the index covers and which query patterns it accelerates. Choose the operator family that matches your query axes to avoid building unnecessary index dimensions.

Operator familyAxes indexedAccelerated query axes
trajgist_ops_zzz only
trajgist_ops_ttt only
trajgist_ops_2dx, yx and y
trajgist_ops_2dtx, y, tx and y; t; x, y, and t
trajgist_ops_3dx, y, zx and y; z; x, y, and z
trajgist_ops_3dtx, y, z, tAll axes — includes all query patterns supported by the five operator families above
trajgist_ops_multiMultiple bounding boxesAccelerates queries — uses multiple bounding boxes per trajectory, at the cost of additional time and storage during index creation
trajgist_ops_multi is the default. It accelerates queries using multiple bounding boxes but takes longer to build and requires more storage than the single-axis operator families.

Examples

Create an index on the t axis:

CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_t);

Create an index on the x and y axes:

CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_2d);

Create an index on the x, y, and t axes:

CREATE INDEX ON table_name USING GIST(traj_col trajgist_ops_2dt);