Reputation: 83566
I am using TimescaleDB as a backend for time-series data. Now I am writing some unit and functional tests against this backend.
I spin up a new database from a PostgreSQL template
The template has continuos aggregated views set up
I load up data from test fixtures using bulk INSERT
, etc.
Now I want my tests to query against those aggregated views
However, as far as I understand, continuous aggregated views are refreshed on a background by TimescaleDB worker processes. For the test to be correct, I need to be sure that all continuous aggregated views are up-to-date.
Is there a way for me to query TimescaleDB for the updateness of a continuous aggregated view and wait until it has properly ingested all data as the result of INSERTs? Or should any INSERT automatically be reflected in all continuous aggregated views on commit?
Upvotes: 0
Views: 1106
Reputation: 3219
In addition to using continuous aggregate policies, which refreshes continuous aggregates on a schedule, it is possible to manually refresh continuous aggregates on demand by calling refresh_continuous_aggregate(). It might be also useful to read this intro. Example from the docs:
CALL refresh_continuous_aggregate('conditions', '2020-01-01', '2020-02-01');
A side note, which might be useful to know: you can tweak if the continuous aggregate should returned only materialized aggregates or calculate from hypertable by setting timescaledb.materialized_only on the view.
Upvotes: 1