percentile_agg()
Aggregate data in a uddsketch, using some reasonable default values, for further calculation of percentile estimates
Aggregate data in a UddSketch, using reasonable default values, for further calculation of percentile estimates. This is
an alternate first step for calculating approximate percentiles. It provides added convenience by using sensible
defaults to create a UddSketch. Internally, it calls uddsketch with a size of 200 and a max_error of 0.001. The
maximum relative error can exceed 0.001 if 200 buckets are too few for the data distribution. You can get it using the
error function.
Use percentile_agg to create an intermediate aggregate from your raw data. This intermediate form can then be used by
one or more accessors in this group to compute final results.
Optionally, multiple such intermediate aggregate objects can be combined using rollup() before an accessor is applied.
Samples
Section titled “Samples”Create a continuous aggregate that stores percentile aggregate objects. These objects can later be used with multiple accessors for retrospective analysis.
CREATE MATERIALIZED VIEW foo_hourlyWITH (timescaledb.continuous)AS SELECT time_bucket('1 h'::interval, ts) as bucket, percentile_agg(value) as pct_aggFROM fooGROUP BY 1;Arguments
Section titled “Arguments”The syntax is:
percentile_agg( value DOUBLE PRECISION) RETURNS UddSketch| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| value | DOUBLE PRECISION | - | ✔ | column of values to aggregate for percentile calculation |
Returns
Section titled “Returns”| Column | Type | Description |
|---|---|---|
| percentile_agg | UddSketch | A percentile estimator object created to calculate percentiles using the UddSketch algorithm |