Skip to content

Behavior of continuous aggregate refresh policies #8691

@FrancescEthon

Description

@FrancescEthon

Hi,

I’m trying to understand the exact behavior of continuous aggregate refresh policies, and I’m running into a mismatch between the docs and the code.

For the following policy:

SELECT add_continuous_aggregate_policy('conditions_summary_hourly',
  start_offset => NULL,
  end_offset => INTERVAL '1 h',
  schedule_interval => INTERVAL '1 h');

The docs say:

“Since the policy runs once every hour (schedule_interval) while also excluding data within the most recent hour (end_offset), it takes up to 2 hours for data written to the hypertable to be reflected in the continuous aggregate.”

This suggests that for an hourly continuous aggregate with end_offset => INTERVAL '1h', data will appear in the aggregate at most 2h later.

Looking at the code, though, it seems that the refresh window is adjusted using compute_inscribed_bucketed_refresh_window. This function “shrinks” the raw refresh window so that only buckets fully enclosed by the window are refreshed. Buckets that partially overlap the exclusion window are skipped.

Imagine that the refresh job runs at :59 past the hour and a data point at 12:01 which belongs to bucket [12:00,13:00).

At the 13:59 run:

  • Raw window end = 13:59 – 1h = 12:59.
  • Inscribed window = buckets ending ≤ 12:00.
  • The [12:00,13:00) bucket overlaps the exclusion window, so it is not refreshed.

At the 14:59 run:

  • The bucket [12:00,13:00) is finally included.

Result: data at 12:01 appears at 14:59 → almost 3h delay, not 2h.

Question

Is this the intended behavior (i.e. buckets are excluded if they overlap the end_offset window at all)?

If so, should the docs be clarified to say that the “up to 2 hours” figure assumes jobs run exactly on bucket boundaries (e.g. :00 for hourly buckets)? Otherwise the effective delay can approach 3h.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions