quantile

quantile

quantile : Quantile aggregation function

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4610
quantile
quantile
1.1.8
FUNC
BSD 2-Clause
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
See Also
lower_quantile
topn
ddsketch
omnisketch
count_distinct
first_last_agg
aggs_for_arrays

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.1.8
18
17
16
15
14
quantile-
RPM
PIGSTY
1.1.8
18
17
16
15
14
quantile_$v-
DEB
PIGSTY
1.1.8
18
17
16
15
14
postgresql-$v-quantile-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
el8.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
el9.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
el9.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
el10.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
el10.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
d12.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
d12.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
d13.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
d13.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
u22.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
u22.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
u24.x86_64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
u24.aarch64
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8
PIGSTY 1.1.8

Source

pig build pkg quantile;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install quantile;		# install via package name, for the active PG version

pig install quantile -v 18;   # install for PG 18
pig install quantile -v 17;   # install for PG 17
pig install quantile -v 16;   # install for PG 16
pig install quantile -v 15;   # install for PG 15
pig install quantile -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION quantile;

Usage

quantile: quantile aggregate functions for PostgreSQL

Provides aggregate functions to compute quantiles. Overloaded for int, bigint, double precision, and numeric.

CREATE EXTENSION quantile;

Functions

FunctionDescription
quantile(value, quantile float)Compute a single quantile (0 to 1)
quantile(value, quantiles float[])Compute multiple quantiles at once, returns array

Examples

-- Compute the median (0.5 quantile)
SELECT quantile(i, 0.5) FROM generate_series(1, 1000) s(i);
-- 500

-- Compute the 95th percentile
SELECT quantile(i, 0.95) FROM generate_series(1, 1000) s(i);

-- Compute all quartiles at once (more efficient than separate calls)
SELECT quantile(i, ARRAY[0.25, 0.5, 0.75])
FROM generate_series(1, 1000) s(i);
-- {250, 500, 750}

Note: Since PostgreSQL 9.4, built-in percentile_cont and percentile_disc functions are available. Consider using those first and only use this extension if it provides measurably better performance for your workload.

Last updated on