Trajectory datasets accumulate large volumes of data over time, and some applications continuously add new trajectory points. To reduce storage costs, export cold trajectory data (data you query or update infrequently) to an Object Storage Service (OSS) bucket using the ST_exportTo function.
Create all required indexes before exporting data to OSS. If you need to create an index, you must do so before importing the data to the OSS bucket.
Prerequisites
Before you begin, ensure that you have:
An OSS bucket and the corresponding AccessKey pair to access it
All indexes required for querying the trajectory data
Export trajectory data to OSS
Run the following statement to export trajectory data from your RDS instance 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"}'
);Parameters
| Parameter | Description |
|---|---|
OSS://<AccessKey>:<AccessKey secret>@<endpoint>/<bucket>/<directory> | The URL of the target OSS bucket. For endpoint format details, see OSS domain names. |
<AccessKey> | The AccessKey ID used to authenticate access to the OSS bucket. |
<AccessKey secret> | The AccessKey secret paired with the AccessKey ID. |
<endpoint> | The OSS endpoint for your bucket's region. Use the internal endpoint (for example, oss-cn-beijing-internal.aliyuncs.com) when your RDS instance and OSS bucket are in the same region to avoid public network transfer costs. |
<bucket>/<directory> | The bucket name and directory path where the trajectory data is stored. |
"compress":"zstd" | The compression method used to compress data. For more information about supported compression methods, see ST_ExportTo. |
Query exported data
After exporting, use the same statement to query trajectory data from OSS.
Query performance decreases for data stored in OSS compared to data in RDS. For latency-sensitive queries, keep the data in RDS.