Skip to content

pgml

Run AI/ML workloads with SQL interface

pgml · Run AI/ML workloads with SQL interface

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1940pgmlpgml2.10.0RAGMITRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLdt-NoYesYesYesnoyes
pgrx=0.12.9

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY2.10.019 18 17 16 15pgml-
RPMPIGSTY2.10.019 18 17 16 15pgml_$v-
DEBPIGSTY2.10.019 18 17 16 15postgresql-$v-pgml-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
el8.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
el9.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
el9.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
el10.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
el10.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
d12.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
d12.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
d13.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
d13.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u22.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u22.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u24.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u24.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u26.x86_64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0
u26.aarch64N/AN/APIGSTY 2.10.0PIGSTY 2.10.0PIGSTY 2.10.0

Source

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

pig install pgml -v 17;   # install for PG 17
pig install pgml -v 16;   # install for PG 16
pig install pgml -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgml';

Create this extension with:

CREATE EXTENSION pgml;

Usage

This extension is lack of maintenance

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

Edit the cluster configuration with patronictl, add pgml to shared_preload_libraries, and specify your venv directory 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/

Table reader