9 Commits

Author SHA1 Message Date
Sven Klemm
cbda1acd4f Record cagg view state in catalog
Record materialized_only state of continuous aggregate view in
catalog and show state in timescaledb_information.continuous_aggregates.
2020-04-14 06:57:33 +02:00
Sven Klemm
2ae4592930 Add real-time support to continuous aggregates
This PR adds a new mode for continuous aggregates that we name
real-time aggregates. Unlike the original this new mode will
combine materialized data with new data received after the last
refresh has happened. This new mode will be the default behaviour
for newly created continuous aggregates.

To upgrade existing continuous aggregates to the new behaviour
the following command needs to be run for all continuous aggregates

ALTER VIEW continuous_view_name SET (timescaledb.materialized_only=false);

To disable this behaviour for newly created continuous aggregates
and get the old behaviour the following command can be run

ALTER VIEW continuous_view_name SET (timescaledb.materialized_only=true);
2020-03-31 22:09:42 +02:00
Matvey Arye
08ad7b6612 Add ignore_invalidation_older_than to continuous aggs
We added a timescaledb.ignore_invalidation_older_than parameter for
continuous aggregatess. This parameter accept a time-interval (e.g. 1
month). if set, it limits the amount of time for which to process
invalidation. Thus, if
	timescaledb.ignore_invalidation_older_than = '1 month'
then any modifications for data older than 1 month from the current
timestamp at insert time will not cause updates to the continuous
aggregate. This limits the amount of work that a backfill can trigger.
This parameter must be >= 0. A value of 0 means that invalidations are
never processed.

When recording invalidations for the hypertable at insert time, we use
the maximum ignore_invalidation_older_than of any continuous agg attached
to the hypertable as a cutoff for whether to record the invalidation
at all. When materializing a particular continuous agg, we use that
aggs  ignore_invalidation_older_than cutoff. However we have to apply
that cutoff relative to the insert time not the materialization
time to make it easier for users to reason about. Therefore,
we record the insert time as part of the invalidation entry.
2019-12-04 15:47:03 -05:00
Sven Klemm
b86e47a8a1 Fix microsoft compiler warnings
The microsoft compiler can't figure out that elog(ERROR) doesn't
return and warns about functions not returning a value in all code
paths. This patch adds pg_unreachable calls to those functions.
2019-09-16 10:13:21 +02:00
Joshua Lockerman
2801c6a5f5 Fix handling of types with custom partitioning
In various places, most notably drop_chunks and show_chunks, we
dispatch based on the type of the "time" column of the hypertable, for
things such as determining which interval type to use. With a custom
partition function, this logic is incorrect, as we should instead be
determining this based on the return type of the partitioning function.

This commit changes all relevant access of dimension.column_type to a
new function, ts_dimension_get_partition_type, which has the correct
behavior: it returns the partitioning function's return type, if one
exists, and only otherwise uses the column type. After this commit, all
references to column_type directly should have a comment explaining why
this is appropriate.

fixes Gihub issue #1250
2019-06-21 13:08:51 -04:00
gayyappan
297b9ed66a Add default index for continuous aggregates
Add indexes for materialization table created by continuous aggregates.
This behavior can be turned on/off by using timescaledb.create_group_indexes parameter
of the WITH clause when the continuous agg is created.
2019-04-30 14:31:03 -04:00
Matvey Arye
6e882ec1bc Adjust retry_period of cont aggs
We lower the retry_period of cont agg jobs from a constant 1 day to
the schedule_interval because 1 day was too long.

The retry time formula is:
retry_period * 2^(consecutive_failures - 1)

So this seems reasonable.

Also changed the update logic to set retry_period to refresh_interval
on WITH clause alters.
2019-04-26 13:08:00 -04:00
Joshua Lockerman
3895e5ce0e Add a setting for max an agg materializes per run
Add a setting max_materialized_per_run which can be set to prevent a
continuous aggregate from materializing too much of the table in a
single run. This will prevent a single run from locking the hypertable
for too long, when running on a large data set.
2019-04-26 13:08:00 -04:00
Matvey Arye
cc862a3c5a Implement WITH options for continuous aggs
1) Change with clause name to 'timescaledb.continuous'

Used to be timescaledb.continuous_agg as a text field, now is a bool.

2) Add more WITH options for continuous aggs

- Refresh lag control the amount by which the materialization will lag
  behind a the maximum current time value.

- Refresh interval controls how often the background materializer is run.

3) Handle ALTER VIEW on continuous aggs

Handle setting WITH options using continuous views.
Block all other ALTER VIEW commands on user and partial views.
2019-04-26 13:08:00 -04:00