Skip to content

arraymath

Array math and operators that work element by element on the contents of arrays

pg_arraymath · Array math and operators that work element by element on the contents of arrays

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4780arraymathpg_arraymath1.1FUNCMITC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.119 18 17 16 15pg_arraymath-
RPMPIGSTY1.1.019 18 17 16 15pg_arraymath_$v-
DEBPIGSTY1.1.019 18 17 16 15postgresql-$v-pg-arraymath-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.1PIGSTY 1.1PIGSTY 1.1PIGSTY 1.1
el8.aarch64N/APIGSTY 1.1PIGSTY 1.1PIGSTY 1.1PIGSTY 1.1
el9.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el9.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
PackageVersionOSORGSIZEFile URL
pg_arraymath_191.1.0el9.x86_64pigsty35.2 KiBpg_arraymath_19-1.1.0-1PGSTY.el9.x86_64.rpm
pg_arraymath_191.1.0el9.aarch64pigsty34.6 KiBpg_arraymath_19-1.1.0-1PGSTY.el9.aarch64.rpm
pg_arraymath_191.1.0el10.x86_64pigsty35.3 KiBpg_arraymath_19-1.1.0-1PGSTY.el10.x86_64.rpm
pg_arraymath_191.1.0el10.aarch64pigsty34.8 KiBpg_arraymath_19-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-arraymath1.1.0d12.x86_64pigsty25.7 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-arraymath1.1.0d12.aarch64pigsty25.5 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-arraymath1.1.0d13.x86_64pigsty25.8 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-arraymath1.1.0d13.aarch64pigsty25.6 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-arraymath1.1.0u22.x86_64pigsty27.2 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-arraymath1.1.0u22.aarch64pigsty27.1 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-arraymath1.1.0u24.x86_64pigsty27.0 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-arraymath1.1.0u24.aarch64pigsty26.8 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-arraymath1.1.0u26.x86_64pigsty26.9 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-arraymath1.1.0u26.aarch64pigsty26.8 KiBpostgresql-19-pg-arraymath_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_arraymath_181.1el8.x86_64pigsty34.2 KiBpg_arraymath_18-1.1-2.git20260702.4822319PGSTY.el8.x86_64.rpm
pg_arraymath_181.1el8.aarch64pigsty33.8 KiBpg_arraymath_18-1.1-2.git20260702.4822319PGSTY.el8.aarch64.rpm
pg_arraymath_181.1.0el9.x86_64pigsty34.9 KiBpg_arraymath_18-1.1.0-1PGSTY.el9.x86_64.rpm
pg_arraymath_181.1.0el9.aarch64pigsty34.2 KiBpg_arraymath_18-1.1.0-1PGSTY.el9.aarch64.rpm
pg_arraymath_181.1.0el10.x86_64pigsty34.9 KiBpg_arraymath_18-1.1.0-1PGSTY.el10.x86_64.rpm
pg_arraymath_181.1.0el10.aarch64pigsty34.6 KiBpg_arraymath_18-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-arraymath1.1.0d12.x86_64pigsty25.5 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-arraymath1.1.0d12.aarch64pigsty25.3 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-arraymath1.1.0d13.x86_64pigsty25.6 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-arraymath1.1.0d13.aarch64pigsty25.3 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-arraymath1.1.0u22.x86_64pigsty27.0 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-arraymath1.1.0u22.aarch64pigsty26.7 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-arraymath1.1.0u24.x86_64pigsty26.7 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-arraymath1.1.0u24.aarch64pigsty26.5 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-arraymath1.1.0u26.x86_64pigsty26.6 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-arraymath1.1.0u26.aarch64pigsty26.5 KiBpostgresql-18-pg-arraymath_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_arraymath_171.1el8.x86_64pigsty34.2 KiBpg_arraymath_17-1.1-2.git20260702.4822319PGSTY.el8.x86_64.rpm
pg_arraymath_171.1el8.aarch64pigsty33.7 KiBpg_arraymath_17-1.1-2.git20260702.4822319PGSTY.el8.aarch64.rpm
pg_arraymath_171.1.0el9.x86_64pigsty34.9 KiBpg_arraymath_17-1.1.0-1PGSTY.el9.x86_64.rpm
pg_arraymath_171.1.0el9.aarch64pigsty34.2 KiBpg_arraymath_17-1.1.0-1PGSTY.el9.aarch64.rpm
pg_arraymath_171.1.0el10.x86_64pigsty34.9 KiBpg_arraymath_17-1.1.0-1PGSTY.el10.x86_64.rpm
pg_arraymath_171.1.0el10.aarch64pigsty34.6 KiBpg_arraymath_17-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-arraymath1.1.0d12.x86_64pigsty25.4 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-arraymath1.1.0d12.aarch64pigsty25.2 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-arraymath1.1.0d13.x86_64pigsty25.5 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-arraymath1.1.0d13.aarch64pigsty25.3 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-arraymath1.1.0u22.x86_64pigsty28.2 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-arraymath1.1.0u22.aarch64pigsty28.0 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-arraymath1.1.0u24.x86_64pigsty26.7 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-arraymath1.1.0u24.aarch64pigsty26.4 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-arraymath1.1.0u26.x86_64pigsty26.6 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-arraymath1.1.0u26.aarch64pigsty26.4 KiBpostgresql-17-pg-arraymath_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_arraymath_161.1el8.x86_64pigsty34.2 KiBpg_arraymath_16-1.1-2.git20260702.4822319PGSTY.el8.x86_64.rpm
pg_arraymath_161.1el8.aarch64pigsty33.7 KiBpg_arraymath_16-1.1-2.git20260702.4822319PGSTY.el8.aarch64.rpm
pg_arraymath_161.1.0el9.x86_64pigsty34.9 KiBpg_arraymath_16-1.1.0-1PGSTY.el9.x86_64.rpm
pg_arraymath_161.1.0el9.aarch64pigsty34.2 KiBpg_arraymath_16-1.1.0-1PGSTY.el9.aarch64.rpm
pg_arraymath_161.1.0el10.x86_64pigsty34.9 KiBpg_arraymath_16-1.1.0-1PGSTY.el10.x86_64.rpm
pg_arraymath_161.1.0el10.aarch64pigsty34.6 KiBpg_arraymath_16-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-arraymath1.1.0d12.x86_64pigsty25.4 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-arraymath1.1.0d12.aarch64pigsty25.2 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-arraymath1.1.0d13.x86_64pigsty25.5 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-arraymath1.1.0d13.aarch64pigsty25.2 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-arraymath1.1.0u22.x86_64pigsty28.1 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-arraymath1.1.0u22.aarch64pigsty28.0 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-arraymath1.1.0u24.x86_64pigsty26.7 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-arraymath1.1.0u24.aarch64pigsty26.4 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-arraymath1.1.0u26.x86_64pigsty26.6 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-arraymath1.1.0u26.aarch64pigsty26.4 KiBpostgresql-16-pg-arraymath_1.1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_arraymath_151.1el8.x86_64pigsty33.6 KiBpg_arraymath_15-1.1-2.git20260702.4822319PGSTY.el8.x86_64.rpm
pg_arraymath_151.1el8.aarch64pigsty33.2 KiBpg_arraymath_15-1.1-2.git20260702.4822319PGSTY.el8.aarch64.rpm
pg_arraymath_151.1.0el9.x86_64pigsty34.4 KiBpg_arraymath_15-1.1.0-1PGSTY.el9.x86_64.rpm
pg_arraymath_151.1.0el9.aarch64pigsty33.6 KiBpg_arraymath_15-1.1.0-1PGSTY.el9.aarch64.rpm
pg_arraymath_151.1.0el10.x86_64pigsty34.5 KiBpg_arraymath_15-1.1.0-1PGSTY.el10.x86_64.rpm
pg_arraymath_151.1.0el10.aarch64pigsty34.1 KiBpg_arraymath_15-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-arraymath1.1.0d12.x86_64pigsty24.9 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-arraymath1.1.0d12.aarch64pigsty24.7 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-arraymath1.1.0d13.x86_64pigsty25.0 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-arraymath1.1.0d13.aarch64pigsty24.9 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-arraymath1.1.0u22.x86_64pigsty27.7 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-arraymath1.1.0u22.aarch64pigsty27.6 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-arraymath1.1.0u24.x86_64pigsty26.2 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-arraymath1.1.0u24.aarch64pigsty26.0 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-arraymath1.1.0u26.x86_64pigsty26.2 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-arraymath1.1.0u26.aarch64pigsty26.0 KiBpostgresql-15-pg-arraymath_1.1.0-1PGSTY~resolute_arm64.deb

Source

pgsql-arraymath-1.1+git20260702.4822319.tar.gz

pig build pkg pg_arraymath;		# 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 pg_arraymath;		# install by package name
pig install arraymath;		# install by extension name

pig install arraymath -v 19;   # install for PG 19
pig install arraymath -v 18;   # install for PG 18
pig install arraymath -v 17;   # install for PG 17
pig install arraymath -v 16;   # install for PG 16
pig install arraymath -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION arraymath;

Usage

arraymath: element-by-element array operations for PostgreSQL

Provides element-by-element operators and utility functions for integer, float, and numeric arrays.

CREATE EXTENSION arraymath;

Operators

All operators are prefixed with @ to indicate element-by-element behavior. Works with array-vs-array (same length or cycling) and array-vs-scalar.

OperatorDescriptionReturns
@=Element-by-element equalityboolean[]
@<Element-by-element less thanboolean[]
@>Element-by-element greater thanboolean[]
@<=Element-by-element less than or equalsboolean[]
@>=Element-by-element greater than or equalsboolean[]
@+Element-by-element additionsame type
@-Element-by-element subtractionsame type
@*Element-by-element multiplicationsame type
@/Element-by-element divisionsame type

Functions

FunctionDescription
array_sum(anyarray)Sum of all elements
array_avg(anyarray)Average of all elements
array_min(anyarray)Minimum element
array_max(anyarray)Maximum element
array_median(anyarray)Median element
array_sort(anyarray)Sort ascending
array_rsort(anyarray)Sort descending

Examples

-- Array vs scalar
SELECT ARRAY[1,2,3,4] @< 4;             -- {t,t,t,f}
SELECT ARRAY[3.4,5.6,7.6] @* 8.1;       -- {27.54,45.36,61.56}

-- Array vs array (cycling shorter array)
SELECT ARRAY[1,2,3,4,5,6] @* ARRAY[1,2]; -- {1,4,3,8,5,12}
SELECT ARRAY[1,2,3] @= ARRAY[3,2,1];     -- {f,t,f}

-- Utility functions
SELECT array_sort(ARRAY[9,1,8,2,7]);     -- {1,2,7,8,9}
SELECT array_sum(ARRAY[1,2,3,4,5]);      -- 15
SELECT array_median(ARRAY[1,2,3,4,5]);   -- 3

Table reader