-- Use terse verbosity, so that the expected output does not depend on the -- error context, which differs between PostgreSQL versions (particularly -- for the COPY ... FROM statements below). \set VERBOSITY terse -- via the tdigest(value, count, compression) aggregate SELECT length(tdigest(1.0::float8, 9223372036854775807::bigint, 10000)::text); length -------- 45786 (1 row) -- the count does not have to be anywhere near the int64 limit, a large enough -- count with a moderate compression is enough SELECT length(tdigest(1.0::float8, 1000000000000000000::bigint, 1000)::text); length -------- 5370 (1 row) -- via the percentile aggregates on the value/count API SELECT tdigest_percentile(1.0::float8, 9223372036854775807::bigint, 10000, 0.5); tdigest_percentile -------------------- 1 (1 row) -- via the trimmed aggregates on the value/count API -- -- The exact value depends on where exactly the centroid boundaries end up, -- so don't compare it to an exact value - it'd be a 1 ULP difference away -- from failing. It just has to be (close to) 1.0, not 0.9 or NULL. SELECT abs(tdigest_avg(1.0::float8, 9223372036854775807::bigint, 10000, 0.1, 0.9) - 1.0) < 1e-12; ?column? ---------- t (1 row)