pgml

Run AL/ML workloads with SQL interface

Overview

PackageVersionCategoryLicenseLanguage
pgml2.10.0RAGMITRust
IDExtensionBinLibLoadCreateTrustRelocSchema
1940pgmlNoYesYesYesYesNopgml
Relatedpg4ml vectorize pg_summarize pg_tiktoken vector vchord vectorscale pg_strom

pgrx=0.12.9

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY2.10.01817161514pgml-
RPMPIGSTY2.10.01817161514pgml_$v-
DEBPIGSTY2.10.01817161514postgresql-$v-pgml-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/A
el8.aarch64N/A
el9.x86_64N/A
el9.aarch64N/A
el10.x86_64N/A
el10.aarch64N/A
d12.x86_64N/A
d12.aarch64N/A
d13.x86_64N/A
d13.aarch64N/A
u22.x86_64N/A
u22.aarch64N/A
PIGSTY 2.10.0
PIGSTY 2.10.0
PIGSTY 2.10.0
PIGSTY 2.10.0
u24.x86_64N/A
u24.aarch64N/A
PIGSTY 2.10.0
PIGSTY 2.10.0
PIGSTY 2.10.0
PIGSTY 2.10.0
u26.x86_64N/A
u26.aarch64N/A

Build

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

pig build pkg pgml         # build RPM / DEB packages

Install

You can install pgml 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 pgml;          # Install for current active PG version
pig ext install -y pgml -v 17  # PG 17
pig ext install -y pgml -v 16  # PG 16
pig ext install -y pgml -v 15  # PG 15
pig ext install -y pgml -v 14  # PG 14
dnf install -y pgml_17       # PG 17
dnf install -y pgml_16       # PG 16
dnf install -y pgml_15       # PG 15
dnf install -y pgml_14       # PG 14
apt install -y postgresql-17-pgml   # PG 17
apt install -y postgresql-16-pgml   # PG 16
apt install -y postgresql-15-pgml   # PG 15
apt install -y postgresql-14-pgml   # PG 14

Preload:

shared_preload_libraries = 'pgml';

Create Extension:

CREATE EXTENSION pgml;

Usage

After installing the pgml extension and python dependencies on all cluster nodes, you can enable pgml on the PostgreSQL cluster.

Configure cluster with patronictl command and add pgml to shared_preload_libraries, and specify your venv dir in pgml.venv:

shared_preload_libraries: pgml, timescaledb, pg_stat_statements, auto_explain
pgml.venv: '/data/pgml'

After that, restart database cluster, and create extension with SQL command:

CREATE EXTENSION vector;        -- nice to have pgvector installed too!
CREATE EXTENSION pgml;          -- create PostgresML in current database
SELECT pgml.version();          -- print PostgresML version string

If it works, you should see something like:

# create extension pgml;
INFO:  Python version: 3.11.2 (main, Oct  5 2023, 16:06:03) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]
INFO:  Scikit-learn 1.3.0, XGBoost 2.0.0, LightGBM 4.1.0, NumPy 1.26.1
CREATE EXTENSION

# SELECT pgml.version(); -- print PostgresML version string
 version
---------
 2.7.8

You are all set! Check PostgresML for more details: https://postgresml.org/docs/guides/use-cases/


Last Modified 2026-07-23: update extension list to 555 (d81fc56)