When tracking moving objects — vehicles, vessels, delivery riders, or IoT sensors — raw coordinate logs quickly become unwieldy. PolarDB for PostgreSQL provides a native trajectory data type that aggregates time-stamped location records into a single, queryable object, making spatio-temporal analysis significantly more efficient than storing individual coordinate rows.
How trajectories work
A trajectory is a time-ordered sequence of locations recorded as an object moves. Each point in the sequence stores at minimum a timestamp and coordinates:
| time | x | y |
|---|---|---|
| 2020-04-11 17:42:30 | 114.35 | 39.28 |
Sampling points can also carry additional attributes. In this example, speed is recorded alongside the coordinates:
| time | x | y | speed |
|---|---|---|---|
| 2020-04-11 17:42:30 | 114.35 | 39.28 | 4.3 |
As the object moves, successive samples form a sequence of trajectory points:
| time | x | y | speed |
|---|---|---|---|
| 2020-04-11 17:42:30 | 114.35 | 39.28 | 4.3 |
| 2020-04-11 17:43:30 | 114.36 | 39.28 | 4.8 |
| 2020-04-11 17:44:30 | 114.35 | 39.29 | 3.5 |
Together, these points form a spatio-temporal trajectory.

What you can do with trajectories
Once raw sampling data is aggregated into a trajectory object, PolarDB for PostgreSQL supports the following operations:
| Operation | Description |
|---|---|
| Compress trajectory points | Reduce the number of stored points, lowering storage costs |
| Calculate intersections | Find where two trajectories overlap |
| Extract sub-trajectories | Slice a portion of a trajectory based on a time range |
| Determine trajectory similarity | Compare movement patterns between two trajectories |