Resources · 91

Means and percentiles: aggregate without hiding slow tasks

Compare performance using consistent populations, units and time windows.

· 4 min

Empty intelligence archive with dossiers and maps AI-generated editorial illustration

What this guide helps achieve

  • Define the population
  • Retain sums and counts
  • Preserve distributions
  • Document precision
  • Read centre and tail together
  • Separate empty groups and unknown values

Quick check

  • Can p95 values be averaged?
  • Why show counts?
  • Should outliers be deleted?

Step-by-step method

  1. 01

    Define the population

    Specify received, completed or successful requests. Retain units, windows, filters and counts. Measure failures separately: excluding them can make an average misleadingly reassuring.

    Output: Measurement contract and exclusions.

  2. 02

    Retain sums and counts

    For disjoint groups with the same scope, overall mean is the sum of values divided by their count. Weight group means by group counts; a simple average of means can distort the result.

    Output: Count and sum table.

  3. 03

    Preserve distributions

    A percentile describes a position in a distribution. Averaging p95 values does not yield overall p95. Retain observations or compatible histograms that can be combined before estimation.

    Output: Retained distribution with units.

  4. 04

    Document precision

    Record quantile method, bucket boundaries and estimation limits. Compare compatible instruments. Wide buckets may prevent distinguishing deterioration near an operational threshold.

    Output: Estimation method and precision.

  5. 05

    Read centre and tail together

    Show counts, means and useful percentiles, then segment slow tasks. Inspect traffic and errors too. A changing mix of tasks can shift an overall metric without changing each task.

    Output: Segmented interpretation tied to action.

  6. 06

    Separate empty groups and unknown values

    A zero count contributes no observations and does not define a zero mean. A missing mean in a non-empty group prevents aggregation. Also check that groups do not overlap: one request must not be counted in two batches.

    Output: Missing-value and double-count checks.

Compare weighted group means

Combine disjoint batches measured in milliseconds using one definition. The fictional example yields 460 ms for 10 observations at 100 ms and 90 at 500 ms. No percentile can be inferred.

Formula: Σ(count × mean) / Σ(count). Empty groups are excluded. This calculator does not save or transmit your values.

Fictional acceptance-test scenarios

These proposed cases are not client observations. Adapt data, permissions and acceptance criteria to your authorised environment.

Situation to exerciseResult to checkEvidence to retain
Two batches: a 100 ms mean over 10 observations and 200 ms over 90.Check the weighted mean: (100 × 10 + 200 × 90) / 100 = 190 ms, not 150 ms.Sums, counts, units and matching measurement scope.
Two services publish only their p95 values.Do not report their average as a global p95; obtain compatible distributions or disclose the limitation.Available observations or buckets and aggregation method.
The dashboard mixes successful requests with fast failures.State the population and compare outcome states before claiming better latency.Filters, states, window and counts for each population.
One group contains two observations but its mean is unknown; another group is genuinely empty.Reject the unknown mean in the non-empty group; exclude the empty group without inventing a zero observation.Counts, missing values, displayed error and included groups.

Reusable worksheet

Complete with your authorised observations. These fields are a working template, not observed results.

FieldInformation to record
MeasureEvent, unit, window and exclusions
GroupsObservation count and sum
QuantilesMethod, buckets and precision
InterpretationSlow segments, errors and traffic

Worked example

Illustrative situation

Fictional example: 10 requests average 100 ms and another 90 average 500 ms.

Decision and expected evidence

The simple mean of the two groups is 300 ms; the mean of all 100 observations is 460 ms. Neither group mean determines p95.

Distinguish the mechanisms

MechanismPurposeCheck or limitation
MeanDescribe average costSensitive to extreme observations
MedianDescribe a central observationDoes not describe the slow tail
p95Inspect the distribution tailSpecify population and estimation

Management indicators

IndicatorWhat it measuresFirst action
CountsIncluded observationsReconcile exclusions
Slow tailPercentile of the distributionReproduce affected tasks
CompositionWeight of each segmentCompare consistent populations

Common pitfalls

  • Sensitive to extreme observations
  • Does not describe the slow tail
  • Specify population and estimation

Frequently asked questions

Can p95 values be averaged?

Not to obtain overall p95. Combine compatible distributions, then calculate or estimate the percentile.

Why show counts?

They enable weighting, reveal small groups and explain changes in population composition.

Should outliers be deleted?

Only under a justified rule. Retain exclusions and check whether they represent real incidents.

Join cardinality, NULL and aggregates

Read the cardinality behind a published number

When a result combines sources, ask what one row represents and how keys were matched. An apparently correct sum can conceal two offsetting errors. Pair counts and identifier coverage provide additional evidence.

  • Document population before and after joining.
  • Do not infer causation from the total alone.
  • Connect the metric definition to actual retained rows.

Inspect pairs and aggregates in the workshop →

PostgreSQL 18 · Table expressions · PostgreSQL 18 · documentation reviewed 2026-10-23

PostgreSQL 18 · Aggregate functions · PostgreSQL 18 · documentation reviewed 2026-10-23

PostgreSQL 18 · Comparison functions · PostgreSQL 18 · documentation reviewed 2026-10-23

Official references

References consulted: . The method and worksheet propose checks to adapt to your context; they do not constitute certification.