lower_quantile

Lower quantile aggregate function

Overview

PackageVersionCategoryLicenseLanguage
lower_quantile1.0.3FUNCBSD 2-ClauseC
IDExtensionBinLibLoadCreateTrustRelocSchema
4620lower_quantileNoYesNoYesNoNo-
Relatedquantile topn ddsketch omnisketch count_distinct first_last_agg

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.0.31817161514lower_quantile-
RPMPIGSTY1.0.31817161514lower_quantile_$v-
DEBPIGSTY1.0.31817161514postgresql-$v-lower-quantile-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
d12.x86_64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
d12.aarch64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
d13.x86_64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
d13.aarch64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
u22.x86_64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
u22.aarch64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
u24.x86_64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
u24.aarch64
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3
PIGSTY 1.0.3

Build

You can build the RPM / DEB packages for lower_quantile using pig build:

pig build pkg lower_quantile         # build RPM / DEB packages

Install

You can install lower_quantile directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install lower_quantile;          # Install for current active PG version
pig ext install -y lower_quantile -v 18  # PG 18
pig ext install -y lower_quantile -v 17  # PG 17
pig ext install -y lower_quantile -v 16  # PG 16
pig ext install -y lower_quantile -v 15  # PG 15
pig ext install -y lower_quantile -v 14  # PG 14
dnf install -y lower_quantile_18       # PG 18
dnf install -y lower_quantile_17       # PG 17
dnf install -y lower_quantile_16       # PG 16
dnf install -y lower_quantile_15       # PG 15
dnf install -y lower_quantile_14       # PG 14
apt install -y postgresql-18-lower-quantile   # PG 18
apt install -y postgresql-17-lower-quantile   # PG 17
apt install -y postgresql-16-lower-quantile   # PG 16
apt install -y postgresql-15-lower-quantile   # PG 15
apt install -y postgresql-14-lower-quantile   # PG 14

Create Extension:

CREATE EXTENSION lower_quantile;

Usage

lower_quantile: lower quantile aggregate for PostgreSQL

Implements the “lower quantile” aggregate, which differs slightly from percentile_disc by returning the value whose rank in the sorted multiset is floor(1 + q*(n-1)).

CREATE EXTENSION lower_quantile;

Functions

FunctionDescription
lower_quantile(value, quantile float)Compute the lower quantile for the given quantile value (0 to 1)

Examples

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

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

This definition is used by some papers (e.g., the DDSketch paper) to formulate accuracy guarantees.


Last Modified 2026-03-12: add pg extension catalog (95749bf)