diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/04_group_type_counts/02_initial_fill.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/04_group_type_counts/02_initial_fill.sql index 286bbc487d..c83c9d4e8e 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/04_group_type_counts/02_initial_fill.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/04_group_type_counts/02_initial_fill.sql @@ -6,4 +6,4 @@ ANALYSE report.group_type_counts; -- A unique index is mandatory for concurrent updates used in the refresh CREATE UNIQUE INDEX group_type_counts_created_week_group_id_sub_type_shared_idx - ON report.group_type_counts (created_week, group_id, sub_type, shared); + ON report.group_type_counts (group_id, sub_type, shared, created_week); diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql index 4121c4ea94..38c139adb2 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql @@ -6,4 +6,4 @@ ANALYSE report.group_bubbled_type_count; -- A unique index is mandatory for concurrent updates used in the refresh CREATE UNIQUE INDEX group_bubbled_type_count_created_week_group_id_idx - ON report.group_bubbled_type_count (created_week, group_id, sub_type, shared); + ON report.group_bubbled_type_count (group_id, sub_type, shared, created_week); diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/01_organization_activity/02_initial_fill.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/01_organization_activity/02_initial_fill.sql index de6b559ca0..df685b3ec7 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/01_organization_activity/02_initial_fill.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/01_organization_activity/02_initial_fill.sql @@ -6,5 +6,7 @@ REFRESH MATERIALIZED VIEW report.organization_activity; ANALYSE report.organization_activity; -- A unique index is mandatory for concurrent updates used in the refresh -CREATE UNIQUE INDEX organization_activity_timescale_period_role_organization_id_idx ON report.organization_activity (timescale, period, role, organization_id); -CREATE INDEX organization_activity_start_date_end_date_idx ON report.organization_activity (start_date, end_date); +CREATE UNIQUE INDEX organization_activity_timescale_period_role_organization_id_idx + ON report.organization_activity (timescale, period, role, organization_id); +CREATE INDEX organization_activity_start_date_end_date_idx + ON report.organization_activity (start_date, end_date); diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/02_organization_annotation_types/02_initial_fill.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/02_organization_annotation_types/02_initial_fill.sql index 8d865ac9fd..d76bb7bf06 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/02_organization_annotation_types/02_initial_fill.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/03_organizations/02_organization_annotation_types/02_initial_fill.sql @@ -7,6 +7,6 @@ ANALYSE report.organization_annotation_types; -- A unique index is mandatory for concurrent updates used in the refresh CREATE UNIQUE INDEX organization_annotation_types_period_timescale_sub_type_idx - ON report.organization_annotation_types (period, timescale, sub_type, shared, organization_id); + ON report.organization_annotation_types (organization_id, timescale, sub_type, shared, period); CREATE INDEX organization_annotation_types_start_date_end_date_idx ON report.organization_annotation_types (start_date, end_date);