- 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
CREATE TIMESERIES POLICY
Function
Used to create a new data retention policy under the current database.
Precautions
-
The name of the newly created data retention policy cannot be renamed with an existing retention policy.
-
The value of
durationshould be greater than or equal to that ofchunkGroupDuration. -
durationandchunkGroupDurationare formatted asnumber + time unit. If the number entered is not an integer, it will be rounded upwards, e.g. 1.2 weeks will be rounded to 2 weeks. -
durationandchunkGroupDurationdo not support negative numbers,durationandchunkGroupDurationsupport the minimum time unit is 1 hour, if the value set is less than 1 hour will be automatically set to 1 hour. -
The value unit of
durationandchunkGroupDurationcan be hour, day, week, month, and year. -
The value range of each unit needs to meet the following condition.
Unit Upper Limit Lower Limit Year 0 296533 Month 0 3558399 Week 0 15250284 Day 0 106751991 Hour 0 2147483647
Syntax Format
CREATE TIMESERIES POLICY [ IF NOT EXISTS ] policy_name WITH (option = value, [...] )option includes:
-
duration: indicates the time-series data retention duration. If the retention duration is exceeded, data will be automatically deleted by chunk group. The value should be greater than or equal to 1 hour. The value can also be 0, indicating that data is permanently reserved meanwhile the time unit can be second, minute, hour, day, week, month, and year.
-
chunkGroupDuration: indicates the temporal granularity. The value cannot be set to 0.
If this parameter is not specified, the system automatically sets it in terms of the
durationparameter. The following are rules to be followed:- If the
durationvalue is lower than 2 days, setchunkGroupDurationto 1 hour. It means that the start time ofchunkGroupDurationshould be an integer, such as 2020-07-10 00:00:00 and 2020-07-10 01:00:00 rather than 2020-07-10 00:10:00 and 2020-07-10 00:10:10. - If the
durationvalue is lower than or equal to 6 months, setchunkGroupDurationto 1 day. It means that thechunkGroupDurationvalue can be a value like 2020-07-10 00:00:00 and 2020-07-11 00:00:00. - If the
durationvalue is greater than 6 months, setchunkGroupDurationto 7 days. It means that the start day of thechunkGroupDurationvalue should be Monday of a week. - If the
durationvalue is greater than 3 years, setchunkGroupDurationto 1 month. It means that the start date of thechunkGroupDurationvalue should be the first day of a month.
- If the
The upper limits of duration and chunkGroupDuration are 231.
There is a default data retention policy named 'infinity' under each database. The default policy has duration='0s', which means the data will never be deleted. chunkGroupDuration='1month'.
Examples
Uqbar=# CREATE TIMESERIES POLICY policy_test WITH (duration = '2 years', chunkGroupDuration='7 days');
CREATE POLICY