Skip to content

counter_zero_time()

Calculate the time when the counter value is predicted to have been zero

Since 1.3.0

Calculate the time when the counter value is predicted to have been zero. This is the x-intercept of the linear fit between counter value and time.

Estimate the time when the counter started

SELECT
id,
bucket,
counter_zero_time(summary)
FROM (
SELECT
id,
time_bucket('15 min'::interval, ts) AS bucket,
counter_agg(ts, val) AS summary
FROM foo
GROUP BY id, time_bucket('15 min'::interval, ts)
) t

The syntax is:

counter_zero_time(
summary CounterSummary
) RETURNS TIMESTAMPTZ
NameTypeDefaultRequiredDescription
summaryCounterSummary-A counter aggregate created using counter_agg
ColumnTypeDescription
counter_zero_timeTIMESTAMPTZThe time when the counter value is predicted to have been zero