Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83566

TimescaleDB: force refresh or stability continuous aggregated views in functional testing

I am using TimescaleDB as a backend for time-series data. Now I am writing some unit and functional tests against this backend.

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

Answers (1)

k_rus
k_rus

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

Related Questions