Remove continuous_aggregate_stats view

Stats for policies are exposed via
the policy_stats view. Remove continuous aggregate
stats view - the thresholds exposed via this
view are not relevant with the new API.
This commit is contained in:
gayyappan 2020-09-11 18:07:07 -04:00 committed by gayyappan
parent 94dd9a33bf
commit 602d9a9bf5
6 changed files with 14 additions and 95 deletions

View File

@ -90,56 +90,6 @@ CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregates as
and N.nspname = cagg.direct_view_schema ) directview
WHERE cagg.mat_hypertable_id = ht.id;
CREATE OR REPLACE VIEW timescaledb_information.continuous_aggregate_stats as
SELECT format('%1$I.%2$I', cagg.user_view_schema, cagg.user_view_name)::regclass as view_name,
CASE _timescaledb_internal.get_time_type(cagg.raw_hypertable_id)
WHEN 'TIMESTAMP'::regtype
THEN _timescaledb_internal.to_timestamp_without_timezone(ct.watermark)::TEXT
WHEN 'TIMESTAMPTZ'::regtype
THEN _timescaledb_internal.to_timestamp(ct.watermark)::TEXT
WHEN 'DATE'::regtype
THEN _timescaledb_internal.to_date(ct.watermark)::TEXT
ELSE ct.watermark::TEXT
END AS completed_threshold,
CASE _timescaledb_internal.get_time_type(cagg.raw_hypertable_id)
WHEN 'TIMESTAMP'::regtype
THEN _timescaledb_internal.to_timestamp_without_timezone(it.watermark)::TEXT
WHEN 'TIMESTAMPTZ'::regtype
THEN _timescaledb_internal.to_timestamp(it.watermark)::TEXT
WHEN 'DATE'::regtype
THEN _timescaledb_internal.to_date(it.watermark)::TEXT
ELSE it.watermark::TEXT
END AS invalidation_threshold,
bgw_job_stat.job_id,
bgw_job_stat.last_start as last_run_started_at,
bgw_job_stat.last_successful_finish as last_successful_finish,
CASE WHEN bgw_job_stat.last_finish < '4714-11-24 00:00:00+00 BC' THEN NULL
WHEN bgw_job_stat.last_finish IS NOT NULL THEN
CASE WHEN bgw_job_stat.last_run_success = 't' THEN 'Success'
WHEN bgw_job_stat.last_run_success = 'f' THEN 'Failed'
END
END as last_run_status,
CASE WHEN bgw_job_stat.last_finish < '4714-11-24 00:00:00+00 BC' THEN 'Running'
WHEN bgw_job_stat.next_start IS NOT NULL THEN 'Scheduled'
END as job_status,
CASE WHEN bgw_job_stat.last_finish > bgw_job_stat.last_start THEN (bgw_job_stat.last_finish - bgw_job_stat.last_start)
END as last_run_duration,
bgw_job_stat.next_start as next_scheduled_run,
bgw_job_stat.total_runs,
bgw_job_stat.total_successes,
bgw_job_stat.total_failures,
bgw_job_stat.total_crashes
FROM
_timescaledb_catalog.continuous_agg as cagg
LEFT JOIN _timescaledb_config.bgw_job as bgw_job
ON ( cagg.mat_hypertable_id = bgw_job.hypertable_id )
LEFT JOIN _timescaledb_internal.bgw_job_stat as bgw_job_stat
ON ( bgw_job.id = bgw_job_stat.job_id )
LEFT JOIN _timescaledb_catalog.continuous_aggs_invalidation_threshold as it
ON ( cagg.raw_hypertable_id = it.hypertable_id)
LEFT JOIN _timescaledb_catalog.continuous_aggs_completed_threshold as ct
ON ( cagg.mat_hypertable_id = ct.materialization_id);
CREATE OR REPLACE VIEW timescaledb_information.data_node AS
SELECT s.node_name, s.owner, s.options
FROM (SELECT srvname AS node_name, srvowner::regrole::name AS owner, srvoptions AS options

View File

@ -533,13 +533,12 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND
classid='pg_catalog.pg_class'::pg_catalog.regclass
AND objid NOT IN (select unnest(extconfig) from pg_extension where extname='timescaledb')
ORDER BY objid::text DESC;
objid
----------------------------------------------------
objid
---------------------------------------------------
timescaledb_information.compression_settings
timescaledb_information.dimensions
timescaledb_information.chunks
timescaledb_information.data_node
timescaledb_information.continuous_aggregate_stats
timescaledb_information.continuous_aggregates
timescaledb_information.policy_stats
timescaledb_information.license
@ -550,7 +549,7 @@ WHERE refclassid = 'pg_catalog.pg_extension'::pg_catalog.regclass AND
_timescaledb_internal.bgw_policy_chunk_stats
_timescaledb_internal.bgw_job_stat
_timescaledb_catalog.tablespace_id_seq
(15 rows)
(14 rows)
-- Make sure we can't run our restoring functions as a normal perm user as that would disable functionality for the whole db
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER

View File

@ -94,14 +94,6 @@ SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::inte
1000
(1 row)
-- even before running, stats shows something
SELECT view_name, invalidation_threshold, job_status, last_run_duration
FROM timescaledb_information.continuous_aggregate_stats;
view_name | invalidation_threshold | job_status | last_run_duration
--------------------------+------------------------+------------+-------------------
test_continuous_agg_view | | |
(1 row)
SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset
-- min distance from end should be 1
SELECT mat_hypertable_id, user_view_schema, user_view_name, bucket_width
@ -473,12 +465,13 @@ view_definition | SELECT time_bucket(2, test_continuous_agg_table."time") AS ti
| FROM test_continuous_agg_table +
| GROUP BY (time_bucket(2, test_continuous_agg_table."time"));
select view_name, invalidation_threshold, job_status, last_run_duration from timescaledb_information.continuous_aggregate_stats where view_name::text like '%test_continuous_agg_view';
-[ RECORD 1 ]----------+-------------------------
view_name | test_continuous_agg_view
invalidation_threshold | 12
job_status | Scheduled
last_run_duration |
select job_status, last_run_duration
from timescaledb_information.policy_stats ps, timescaledb_information.continuous_aggregates cagg
where cagg.view_name::text like '%test_continuous_agg_view'
and cagg.materialization_hypertable = ps.hypertable;
-[ RECORD 1 ]-----+----------
job_status | Scheduled
last_run_duration |
\x off
DROP MATERIALIZED VIEW test_continuous_agg_view;

View File

@ -83,25 +83,6 @@ view_definition | SELECT time_bucket('@ 1 hour'::interval, device_re
| FROM device_readings +
| GROUP BY (time_bucket('@ 1 hour'::interval, device_readings.observation_time)), device_readings.device_id;
--You can also view information about your background workers.
--Note: (some fields are empty because there are no background workers used in tests)
SELECT * FROM timescaledb_information.continuous_aggregate_stats;
-[ RECORD 1 ]----------+-----------------------------
view_name | device_summary
completed_threshold |
invalidation_threshold | Sun Dec 30 22:00:00 2018 PST
job_id |
last_run_started_at |
last_successful_finish |
last_run_status |
job_status |
last_run_duration |
next_scheduled_run |
total_runs |
total_successes |
total_failures |
total_crashes |
\x
-- Refresh interval
--

View File

@ -83,10 +83,6 @@ CREATE MATERIALIZED VIEW test_continuous_agg_view
SELECT add_continuous_aggregate_policy('test_continuous_agg_view', NULL, 4::integer, '12 h'::interval);
-- even before running, stats shows something
SELECT view_name, invalidation_threshold, job_status, last_run_duration
FROM timescaledb_information.continuous_aggregate_stats;
SELECT id as raw_table_id FROM _timescaledb_catalog.hypertable WHERE table_name='test_continuous_agg_table' \gset
-- min distance from end should be 1
@ -275,7 +271,10 @@ where view_name::text like '%test_continuous_agg_view';
select view_name, view_definition from timescaledb_information.continuous_aggregates
where view_name::text like '%test_continuous_agg_view';
select view_name, invalidation_threshold, job_status, last_run_duration from timescaledb_information.continuous_aggregate_stats where view_name::text like '%test_continuous_agg_view';
select job_status, last_run_duration
from timescaledb_information.policy_stats ps, timescaledb_information.continuous_aggregates cagg
where cagg.view_name::text like '%test_continuous_agg_view'
and cagg.materialization_hypertable = ps.hypertable;
\x off

View File

@ -51,9 +51,6 @@ SELECT * FROM device_summary WHERE metric_spread = 1800 ORDER BY bucket DESC, de
\x
SELECT * FROM timescaledb_information.continuous_aggregates;
--You can also view information about your background workers.
--Note: (some fields are empty because there are no background workers used in tests)
SELECT * FROM timescaledb_information.continuous_aggregate_stats;
\x
-- Refresh interval