From 507c65e03afab94bac88c3a2493162c9d4da7b90 Mon Sep 17 00:00:00 2001 From: yuenmichelle1 Date: Mon, 6 Nov 2023 13:59:31 -0600 Subject: [PATCH] adding comment on migration to explain how often cagg refresh policies are run and how far they look back --- ...0457_add_continuous_aggregate_refresh_policies.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/db/migrate/20231106170457_add_continuous_aggregate_refresh_policies.rb b/db/migrate/20231106170457_add_continuous_aggregate_refresh_policies.rb index 4194104..aa32210 100644 --- a/db/migrate/20231106170457_add_continuous_aggregate_refresh_policies.rb +++ b/db/migrate/20231106170457_add_continuous_aggregate_refresh_policies.rb @@ -1,5 +1,17 @@ # frozen_string_literal: true +# These refresh policies have a start_offset of 3 days, because that is the smallest possible starting offset (anything smaller will get a `refresh window is too small` db error) +# These refresh policies will look back at the associated tables (classification_events, comment_events, or classification_user_groups) for the past 3 days through the last hour of when the refresh job is run, and re-compute the continuous aggregate. + +# These refresh policies run everyday, if we want to change the frequency refresh policies are run, we will need to update the `scheduling_interval` of the refresh policy + +# Eg. +# +# Refresh Continuous Aggregate Job is run today Nov 6th 1:47PM CST, the job will look at the classification_events table for the past 3 days (Nov 3rd) through the past hour (Nov 6th 12:47 PM CST), and will check for any changes in the classification_events table that have NOT been calculated in previous refresh jobs and then update the caggs with updated calculations. + +# More on refresh policies for continuous aggregates found here: +# https://docs.timescale.com/api/latest/continuous-aggregates/add_continuous_aggregate_policy/ + class AddContinuousAggregateRefreshPolicies < ActiveRecord::Migration[7.0] # we have to disable the migration transaction because creating materialized views within it is not allowed. disable_ddl_transaction!