intercept()

The intercept of the least squares fit line computed from the adjusted counter values and times input in the CounterSummary. This corresponds to the projected value at the PostgreSQL epoch (2000-01-01 00:00:00+00). This is useful for drawing the best fit line on a graph, using the slope and the intercept.

  1. intercept(
  2. summary CounterSummary
  3. ) RETURNS DOUBLE PRECISION

For more information about counter aggregation functions, see the hyperfunctions documentation.

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary from a counter_agg call

Returns

NameTypeDescription
interceptDOUBLE PRECISIONThe intercept of the least squares fit line computed from the points input to the CounterSummary

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. intercept(summary)
  5. FROM (
  6. SELECT
  7. id,
  8. time_bucket('15 min'::interval, ts) AS bucket,
  9. counter_agg(ts, val) AS summary
  10. FROM foo
  11. GROUP BY id, time_bucket('15 min'::interval, ts)
  12. ) t