-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ CREATE TABLE @[email protected]_config( | |
retention_duration interval, | ||
tier_duration interval, | ||
compression_duration interval, | ||
CONSTRAINT policy_duration_order_check | ||
CHECK(compression_duration < tier_duration | ||
CONSTRAINT policy_duration_order_check | ||
CHECK(compression_duration < tier_duration | ||
AND tier_duration < retention_duration | ||
AND compression_duration < retention_duration)); | ||
|
||
|
@@ -669,9 +669,9 @@ BEGIN | |
END; | ||
$function$; | ||
|
||
-- This function will call tier function for the qualified partitions | ||
-- This function will call tier function for the qualified partitions | ||
-- (which must be time-series enabled) and a compression offset, all partitions falling | ||
-- entirely behind the offset (from the present time). | ||
-- entirely behind the offset (from the present time). | ||
CREATE OR REPLACE FUNCTION @[email protected]_tier_policy(target_table_id regclass, comp_offset interval) | ||
RETURNS void | ||
LANGUAGE plpgsql | ||
|
@@ -707,12 +707,13 @@ BEGIN | |
part_row.partition_tablename); | ||
|
||
IF part_end < (now() - comp_offset) THEN | ||
EXECUTE 'SELECT tier.table(' || | ||
chr(39)|| part_row.partition_schemaname || '.' || part_row.partition_tablename || | ||
EXECUTE 'SELECT tier.table(' || | ||
chr(39)|| part_row.partition_schemaname || '.' || part_row.partition_tablename || | ||
chr(39)|| ')'; | ||
END IF; | ||
END LOOP; | ||
END; | ||
$function$; | ||
|
||
|
||
--Tier data every fortnight (15 days). | ||
SELECT cron.schedule('timeseries-tiering', '0 23 15 * *', $$SELECT @[email protected]_tier_policy(table_id, tier_duration) FROM ts_config;$$); |