Skip to content

[Enhancement]: Allow refreshing continuous aggregates by conditions that aren’t temporal #8011

@ollz272

Description

@ollz272

What type of enhancement is this?

API improvement

What subsystems and features will be improved?

Continuous aggregate

What does the enhancement do?

This enhancement would allow specifying a condition on which a continuous aggregates data can be refreshed that isn’t based on temporal fields.

Something like this:

CREATE MATERIALIZED VIEW example WITH (timescaledb.continuous) AS
SELECT 
    time_bucket('1 day', time) AS bucket,
    equipment.equipment_id,
    datapoint.value * equipment.max_power
FROM datapoint
JOIN device ON datapoint.device_id = device.device_id
JOIN equipment ON equipment.equipment_id = device.equipment_id
WHERE device.device_type = 'power_usage'
GROUP BY bucket, devices.name
WITH NO DATA;

So when the equipments max power changes, we'd like to update the cagg for any devices on that equipment in the cagg. So if the max power changed on equipment with id 1:
refresh_continuous_aggregate('conditions_by_day', 'select * from example where equipment_id = 1)Then this would find all the rows with equipment id 1, invalidate them, and repopulate the agg table with those values.

Implementation challenges

I think it would be nice to have it be an optional argument/different way of using the existing function, but it could also be something else.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions