- About Uqbar
- Release Note
- Uqbar Installation
- Uqbar Management
- Data Retention Policy
- Time-Series Table Management
- Time-Series Data Write
- Data Compression
- Data Deletion
- Data Query
- Continuous Aggregation
- Time-Series Views
- Cluster Management
- Backup and Restoration
- Security
- GUC Parameters
- SQL Syntax
- Third Party Tools Support
- Glossary
Data Deletion
Time-series data is usually time-sensitive, and data operations are basically focused on the latest data. Users can automatically delete data that exceeds the retention period by configuring data retention policies. Alternatively, users can perform data deletion manually by calling the delete interface.
Automatic Deletion of Data
The data retention policy of the time-series table is determined when the time-series table is created. When the right boundary of the chunkgroup where the data in the time-series table is located is earlier than the current time minus the data retention time, the system will automatically delete the data in the whole chunkgroup in the background.
Manual Deletion of Data
You can manually delete the data by calling the function.
Examples
SELECT * FROM timeseries_catalog.drop_ts_outdate_cg('weather', now());
SELECT * FROM timeseries_catalog.drop_ts_outdate_cg('public.weather', now()+ '1 h'::interval);
NOTICE: timeseries table weather outdate boundary is 2022-10-31 12:58:01.641916+08
NOTICE: chunkgroup 24773 boundary is 2022-07-27 04:00:00+08
NOTICE: chunkgroup 24773 with boundary(2022-07-27 04:00:00+08) is out of date.
NOTICE: drop chunkgroup 24773 of rel 24760
NOTICE: chunkgroup 24780 boundary is 2025-10-18 09:00:00+08
NOTICE: chunkgroup 24787 boundary is 2025-10-18 11:00:00+08
NOTICE: chunkgroup 24794 boundary is 2025-10-18 12:00:00+08
NOTICE: chunkgroup 24801 boundary is 2030-07-28 06:00:00+08
The first parameter of the manual delete function is used to specify the time-series table, and the second parameter specifies the time to trigger data deletion. When the expired delete function is called, an automatic delete action will be triggered immediately, and the automatic delete takes the second parameter of the function as the current system time for data expiration check.
When the function is executed, it will output a prompt message to show the expiration boundary of each chunkgroup in the time-series table, and it will also output a message to show the information of the deleted chunkgroup.
If the retention policy set in the time-series table is permanent, it cannot be deleted manually by calling the delete function.