Use OSS buckets
Trajectory datasets grow continuously and can become large. Data that is rarely queried or updated—cold data—does not need to stay in high-performance database storage. You can offload cold trajectory data to an Object Storage Service (OSS) bucket to reduce storage costs. The data remains queryable after the export, though with lower performance than local storage.
How OSS storage works
When data is stored in the database, it supports fast queries and index lookups. When data is moved to an OSS bucket, queries still work, but with higher latency because the data is not stored locally.
Once data is in OSS, you cannot add indexes to it. Plan your indexing strategy before you export.
Export trajectory data to OSS
Create all indexes on your trajectory data before running the export. After data is in OSS, you cannot create indexes on it.
Run the following statement to export trajectory data to an OSS bucket:
UPDATE trajectory_table
SET traj = ST_ExportTo(
traj,
'OSS://<AccessKey>:<AccessKey Secret>@oss-cn-beijing-internal.aliyuncs.com/<bucket>/<directory>',
'{"compress":"zstd"}'
);| Parameter | Description |
|---|---|
<AccessKey>:<AccessKey Secret> | The AccessKey pair used to authenticate access to the OSS bucket |
oss-cn-beijing-internal.aliyuncs.com | The OSS endpoint. For details, see OSS domain names |
<bucket>/<directory> | The bucket name and directory path where the trajectory data is stored |
"compress":"zstd" | The compression method applied during export. For supported options, see ST_ExportTo |
After the export completes, use the same UPDATE statement to query the data.
Limitations
Query performance is lower for OSS-stored data. Queries against data in OSS are slower than queries against local storage. OSS access has higher latency because the data is not stored on the high-performance database tier. Consider this trade-off when deciding which data to offload.
Indexes must be created before export. You cannot create indexes on trajectory data after it is in OSS. If your queries require an index, create it before running the export statement.