Specify index types

更新时间:
复制 MD 格式

GanosBase supports two index types for trajectory data. They differ in how they partition a trajectory into bounding boxes, which determines query filtering precision and storage cost.

Index types

Index typeHow it worksStorageFiltering efficiency
Single bounding boxRepresents each trajectory as one bounding boxLowerLower
Multi-bounding boxSplits a trajectory into multiple segments, each as a separate bounding boxHigherHigher — spatial queries are at least twice as fast as queries without bounding box indexing

Single bounding box

Available operator classes: trajgist_2d (two-dimensional), trajgist_3dt (three-dimensional and time).

Multi-bounding box

Operator class: multi.

Multi-bounding box indexing is not supported in some versions of GanosBase.

View the default index type

Run the following queries to check the current default index configuration:

-- List all trajectory-related operator classes and identify the default
SELECT * FROM pg_opclass WHERE opcname LIKE '%traj%' AND opcdefault = true;

-- Show the default split configuration (applies to trajgist_ops_multi)
SHOW ganos.trajectory.index_split_config;

Create and manage indexes

Create a two-dimensional and time index

CREATE INDEX idx_2dt ON trajectory_table USING GiST(traj trajgist_2dt);

Create a multi-bounding box index

Before creating a multi-bounding box index, configure how many bounding boxes represent each trajectory. The following example sets four bounding boxes:

SET ganos.trajectory.index_split_config = '{"cut_point.even_divide":4}';

Then create the index:

CREATE INDEX idx_2dt ON trajectory_table USING GiST(traj multi);

Drop an index

DROP INDEX idx_2dt;