|
19 | 19 | END |
20 | 20 | $$ SET search_path = pg_catalog, pg_temp; |
21 | 21 |
|
| 22 | +CREATE OR REPLACE FUNCTION check_cagg_large_materialization_range() RETURNS void LANGUAGE plpgsql AS |
| 23 | +$$ |
| 24 | +DECLARE |
| 25 | + cagg regclass; |
| 26 | + range text; |
| 27 | +BEGIN |
| 28 | + FOR cagg, range IN |
| 29 | + SELECT |
| 30 | + format('%I.%I', c.user_view_schema, c.user_view_name)::regclass AS continuous_aggregate, |
| 31 | + CASE |
| 32 | + WHEN d.column_type =ANY('{int4,int8}'::regtype[]) THEN (r.greatest_modified_value - r.lowest_modified_value)::text |
| 33 | + WHEN d.column_type =ANY('{timestamp,timestamptz}'::regtype[]) THEN _timescaledb_functions.to_interval(r.greatest_modified_value - r.lowest_modified_value)::text |
| 34 | + END AS range |
| 35 | + FROM _timescaledb_catalog.continuous_aggs_materialization_ranges r |
| 36 | + JOIN _timescaledb_catalog.continuous_agg c ON c.mat_hypertable_id=r.materialization_id |
| 37 | + JOIN _timescaledb_catalog.continuous_aggs_bucket_function f on f.mat_hypertable_id=c.mat_hypertable_id |
| 38 | + JOIN _timescaledb_catalog.dimension d ON d.hypertable_id=c.mat_hypertable_id |
| 39 | + WHERE |
| 40 | + CASE |
| 41 | + WHEN d.column_type =ANY('{int4,int8}'::regtype[]) THEN (r.greatest_modified_value - r.lowest_modified_value) > 250 * f.bucket_width::int |
| 42 | + WHEN d.column_type =ANY('{timestamp,timestamptz}'::regtype[]) THEN _timescaledb_functions.to_interval(r.greatest_modified_value - r.lowest_modified_value) > 250 * f.bucket_width::interval |
| 43 | + END |
| 44 | + LOOP |
| 45 | + RAISE WARNING 'Continuous aggregate % has large materialization range ''%''.', cagg, range; |
| 46 | + END LOOP; |
| 47 | +END |
| 48 | +$$ SET search_path = pg_catalog, pg_temp; |
| 49 | + |
22 | 50 | CREATE OR REPLACE FUNCTION check_job_failures() RETURNS void LANGUAGE plpgsql AS |
23 | 51 | $$ |
24 | 52 | DECLARE |
@@ -119,6 +147,7 @@ BEGIN |
119 | 147 | PERFORM check_deprecated_features(); |
120 | 148 | PERFORM check_job_failures(); |
121 | 149 | PERFORM check_compressed_chunk_batch_sizes(); |
| 150 | + PERFORM check_cagg_large_materialization_range(); |
122 | 151 | END |
123 | 152 | $$; |
124 | 153 |
|
|
0 commit comments